How to extract histogram from @benchmark results

How can we see the histogram results as shown in from the Julia prompt?

Apparently, you can use display which will be very close to what you get in the Julia prompt. println will give you the gist of it, dump lots of attributes.

Yes, the REPL calls display. However, the output of display in general may depend on the environment (e.g. it may be an image in some environments), and the environment also determines which I/O device/stream the output goes to. If you specifically want the text output, and want it sent to a particular stream io, you can do:

show(io, "text/plain", x)

e.g. with io = stdout, which is what display calls under the hood for the default text output situation.

See also the summary of output functions which should be in the next (1.12) version of the Julia manual.

(The actual data of the histogram from x = @benchmark foo is in x.times, which is just a raw list of timings, from which you can plot a histogram using any of the plotting packages.)

3 Likes