# Get unit with @benchmark or set unit to "s"

**URL:** <https://discourse.julialang.org/t/get-unit-with-benchmark-or-set-unit-to-s/101664>\
**Category:** General Usage\
**Tags:** benchmark, benchmarktools, time\
**Created:** [July 15, 2023, 11:10pm UTC](https://discourse.julialang.org/t/get-unit-with-benchmark-or-set-unit-to-s/101664 "2023-07-15T23:10:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sisisi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sisisi/32/51469_2.png) [@Sisisi](https://discourse.julialang.org/u/Sisisi)\
**Post date:** [July 15, 2023, 11:10pm UTC](https://discourse.julialang.org/t/get-unit-with-benchmark-or-set-unit-to-s/101664/1 "2023-07-15T23:10:22Z")

</div>

Hello,

I know how to get the mean, median… about @benchmark, nonetheless, those values are given in the suitable unit (ms, µs, ns) but I need to know with Julia what is this unit. Or, else, set the unit to “second”.

I have to do lot of tests and executions times must be homogenous.

Thanks

---

<div class="post-metadata">

**Author:** ![Tortar](https://avatars.discourse-cdn.com/v4/letter/t/6bbea6/32.png) [@Tortar](https://discourse.julialang.org/u/Tortar)\
**Post date:** [July 16, 2023, 1:13am UTC](https://discourse.julialang.org/t/get-unit-with-benchmark-or-set-unit-to-s/101664/2 "2023-07-16T01:13:47Z")

</div>

The unit of measure is `ns` when you inspect the `times` vector inside the result of `@benchmark`:

```julia
julia> using BenchmarkTools

julia> b = @benchmark rand(10000)
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
 Range (min … max): 8.800 μs … 3.340 ms ┊ GC (min … max): 0.00% … 98.78%
 Time (median): 9.800 μs ┊ GC (median): 0.00%
 Time (mean ± σ): 20.111 μs ± 61.081 μs ┊ GC (mean ± σ): 11.34% ± 3.98%

  █▇ ▂▆▆▅▁ ▂
  ██▆▅▆▄▄▅▄▅▄▄▃▄▁▁▁▁▁▁▄██████▇▆▆▇▆▇▇▆▆▅▃▅▁▄▃▃▅▄▄▄▄▅▆▆▄▅▄▆▆▆▇█ █
  8.8 μs Histogram: log(frequency) by time 62.3 μs <

 Memory estimate: 78.17 KiB, allocs estimate: 2.

julia> minimum(b.times)
8800.0

```
