Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature suggestion: @ballocs #272

Open
claforte opened this issue Dec 19, 2021 · 1 comment
Open

Feature suggestion: @ballocs #272

claforte opened this issue Dec 19, 2021 · 1 comment

Comments

@claforte
Copy link

claforte commented Dec 19, 2021

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.

@gdalle
Copy link
Collaborator

gdalle commented Jun 13, 2023

Probably fixed by #292

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants