# Why is there a large range in evaluation time when using map?

**URL:** https://discourse.julialang.org/t/why-is-there-a-large-range-in-evaluation-time-when-using-map/96286
**Category:** New to Julia
**Created:** [March 18, 2023, 9:42pm UTC](https://discourse.julialang.org/t/why-is-there-a-large-range-in-evaluation-time-when-using-map/96286 "2023-03-18T21:42:30Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![maxdrohde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxdrohde/32/47856_2.png) [@maxdrohde](https://discourse.julialang.org/u/maxdrohde)
#### Post date: [March 18, 2023, 9:42pm UTC](https://discourse.julialang.org/t/why-is-there-a-large-range-in-evaluation-time-when-using-map/96286/1 "2023-03-18T21:42:30Z")

</div>

When I was trying to practice benchmarking some code, I ran into an unexpected result.

I ran

```julia
@benchmark map(x -> x^2, 1:10^6)

```

and obtained the following results.

```julia
BenchmarkTools.Trial: 3230 samples with 1 evaluation.
 Range (min … max): 512.863 μs … 27.653 ms ┊ GC (min … max): 0.00% … 96.25%
 Time (median): 860.196 μs ┊ GC (median): 0.00%
 Time (mean ± σ): 1.545 ms ± 2.938 ms ┊ GC (mean ± σ): 45.57% ± 22.36%

  ▃█                                                            
  ██▄▄▁▁▁▁▁▁▅▃▃▄▃▁▁▁▃▃▃▄▃▅▄▅▅▅▅▅▄▆▄▅▅▆▇▆▆▅▇▄▅▄▁▄▄▅▅▄▄▄▄▁▃▅▄▄▅▄ █
  513 μs Histogram: log(frequency) by time 16.6 ms <

```

Could anyone explain why there is such a large range between the slowest and fastest evaluation times (512.863 μs … 27.653 ms)?

---

<div class="post-metadata">

### Author: ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)
#### Post date: [March 18, 2023, 9:53pm UTC](https://discourse.julialang.org/t/why-is-there-a-large-range-in-evaluation-time-when-using-map/96286/2 "2023-03-18T21:53:26Z")

</div>

> [@maxdrohde](#):
>
> `GC (min … max): 0.00% … 96.25%`

I would guess garbage collection. It doesn’t need to trigger every run, so sometimes it takes 0% of your runtime, but sometimes it takes 96%, according to the benchmark outputs here.
