Save @btime output

@btime just prints the result (just like @time). If you want something back you should use @benchmark:

julia> using BenchmarkTools

julia> b = @benchmark rand(2,2);

julia> b
BenchmarkTools.Trial: 
  memory estimate:  112 bytes
  allocs estimate:  1
  --------------
  minimum time:     40.862 ns (0.00% GC)
  median time:      43.809 ns (0.00% GC)
  mean time:        46.494 ns (1.74% GC)
  maximum time:     430.152 ns (88.88% GC)
  --------------
  samples:          10000
  evals/sample:     988

julia> min = minimum(b)
BenchmarkTools.TrialEstimate: 
  time:             40.862 ns
  gctime:           0.000 ns (0.00%)
  memory:           112 bytes
  allocs:           1

julia> min.time
40.86234817813765
11 Likes