Measuring and storing execution time in a variable

I want to measure the time from the moment the code enters pmap and exit it. Also, I want to store it in a variable. So is there a way I can store the output of @time or is there a julia package that does it more efficiently?

using Distributed
addprocs(4)

@everywhere function sqr(x)
   return x^2
end

pmap(x->sqr(x), 1:100)

I believe I am looking for something similar to tic() and toc() which are no more available in current julia version (1.5.0)

1 Like

You can use @elapsed. There’s also @timed

2 Likes

Thank you for the reply @dpsanders. I want to measure the wall time elapsed during pmap execution. I am not very sure if @elapsed and @timed measure the wall time and how are they different. I fear that because of parallelization (pmap), it might give weird time outputs.