Save benchmark results

How do I save benchmark results from BenchmarkTools? In the REPL, just typing the variable gives a nice looking report. If I try to output to a file (using println or show), it gives the short single-line form…

julia> b
BenchmarkTools.Trial: 
  memory estimate:  153.16 MiB
  allocs estimate:  1002737
  --------------
  minimum time:     164.029 ms (5.97% GC)
  median time:      266.091 ms (40.97% GC)
  mean time:        262.904 ms (32.59% GC)
  maximum time:     411.212 ms (45.30% GC)
  --------------
  samples:          5
  evals/sample:     1

julia> show(b)
Trial(164.029 ms)

The REPL display is apparently equivalent to

show(STDOUT,MIME"text/plain"(),b)

which should generalize to other files.

3 Likes