Hi, I am trying to measure the total time used to execute a nested for-loops. I used @elapsed
but it seems to only return the time used by one of the inner loops. A MWE is as follows:
function f(m,n)
s = SharedArray{Float64}(m)
for i = 1:m
@distributed for j = 1:n
s[i] = s[i] + rand(1)[1]
end
end
return s
end
@elapsed f(500, 1e7)
The above MWE returns 0.000486948
, which is not what I need because f(500, 1e7)
takes over a minute to run. I tried the TickTock
package too and it also has a similar issue.
Therefore, I am wondering whatβs the appropriate way to count the time required. In the above MWE, I want to count the time required to run f(500, 1e7)
, not the time used by one of the loops inside the function f
.
Thanks for the help in advance!