Chairmarks.jl
Chairmarks.jl copied to clipboard
Suggestion to Follow BenchmarkTools More Closely
Just a couple of suggestions for this superb blazingly fast package! In summary, I propose following BenchmarkTools
more closely regarding layout.
Thanks for your work!
- Adding "0 allocations: 0 bytes" when there are no allocations, instead of printing nothing. This follows
@btime
and is also consistent when there's at least one allocation with @b. Example
7.107 ns (0 allocations: 0 bytes) # this is @btime
7.300 ns # this is @b
# but
34.694 ns (1 allocation: 896 bytes) # this is @btime
33.846 ns (1 allocs: 896 bytes) # this is @b
It might seem trivial, but it becomes important when you have several lines of results, you're new to the package, and for teaching.
- Add
display
by default as BenchmarkTools to reduce boilerplate code. Right now, to get the same results when you execute a whole code snippet, we need to explicitly adddisplay
to see the result. Example:
using BenchmarkTools
using Chairmarks
x = rand(100)
foo1(x) = x^2
foo2(x) = x^3
# this displays all the results directly when the whole code is executed
@btime foo1.($x)
@btime foo2.($x)
# you need to add display to get the same behavior as above
display(@b foo1.($x))
display(@b foo2.($x))
- This is also a suggestion, but probably it's too late. Maybe change
@b
for a more explicit name? I can imagine that reading code with@b
without any context calls for confusion.