BenchmarkTools.jl
BenchmarkTools.jl copied to clipboard
Feature suggestion: @ballocs
Hi, thanks for making this fantastic module! One of the many reasons I love Julia. :-)
I think it would be great if BenchmarkTools came with a macro to report the number of allocations (not bytes), i.e. like @ballocated, but return alloc(...).
This seems to work... maybe this can be considered for inclusion directly in this module?
macro ballocs(args...)
return esc(quote
$BenchmarkTools.allocs($BenchmarkTools.minimum($BenchmarkTools.@benchmark $(args...)))
end)
end
I use it in my project ( https://github.com/claforte/RayTracingWeekend.jl )'s tests to keep the number of heap allocations to a minimum.
Probably fixed by #292