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

Conditional profile scopes #222

Closed
emilk opened this issue Jul 12, 2024 · 0 comments · Fixed by #224
Closed

Conditional profile scopes #222

emilk opened this issue Jul 12, 2024 · 0 comments · Fixed by #224
Assignees
Labels
enhancement New feature or request

Comments

@emilk
Copy link
Collaborator

emilk commented Jul 12, 2024

Sometimes I find myself wishing there was a way to only instrument a piece of code if some condition is met, to reduce overhead:

fn do_stuff(n: usize) {
	puffin::profile_scope_if!(10_000 < n, "processing lots of data");
	for i in 0..n {}
}

If do_stuff is called once with a big n, we get a profile scope.
If do_stuff is called a million times with a small n, we don't pay the overhead of the profiling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant