# Measuring and storing execution time in a variable

**URL:** <https://discourse.julialang.org/t/measuring-and-storing-execution-time-in-a-variable/45236>\
**Category:** Performance\
**Tags:** question, distributed, pmap, time\
**Created:** [August 20, 2020, 4:10am UTC](https://discourse.julialang.org/t/measuring-and-storing-execution-time-in-a-variable/45236 "2020-08-20T04:10:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![trathi](https://avatars.discourse-cdn.com/v4/letter/t/7c8e57/32.png) [@trathi](https://discourse.julialang.org/u/trathi)\
**Post date:** [August 20, 2020, 4:10am UTC](https://discourse.julialang.org/t/measuring-and-storing-execution-time-in-a-variable/45236/1 "2020-08-20T04:10:17Z")

</div>

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?

```julia
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)

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [August 20, 2020, 4:40am UTC](https://discourse.julialang.org/t/measuring-and-storing-execution-time-in-a-variable/45236/2 "2020-08-20T04:40:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![trathi](https://avatars.discourse-cdn.com/v4/letter/t/7c8e57/32.png) [@trathi](https://discourse.julialang.org/u/trathi)\
**Post date:** [August 20, 2020, 4:50am UTC](https://discourse.julialang.org/t/measuring-and-storing-execution-time-in-a-variable/45236/3 "2020-08-20T04:50:03Z")

</div>

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.
