Dear users,

I would like to speed up the following code.

function essai(n,s1,s2)
  a = zeros(Int64,n)
  ss1::Float64 = 0.
  ss2::Float64 = 0.
  @inbounds begin
    for k=1:n
      for i=1:length(s1)
        ss1 = s1[i]
        for j=1:length(s2)
          ss2 = s2[j]
          if ss1>ss2
            a[k] += 1
          end
        end
      end
    end
  end
end

a = rand(1,5000)
b = rand(1,5000)
essai(1,a,b)
@time essai(200,a,b)

On my computer, if I remove the *if*, it runs in 2ms and 13s otherwise. 
Could it be there is a way to speed it up without change the "algorithm"?

Thank you for your help


Reply via email to