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

Asynchronous profiling #246

Open
rivertam opened this issue Dec 11, 2018 · 5 comments
Open

Asynchronous profiling #246

rivertam opened this issue Dec 11, 2018 · 5 comments
Labels
Bigger Project A large project, probably involving major internal changes as well as new API surface Enhancement

Comments

@rivertam
Copy link

rivertam commented Dec 11, 2018

Hey, sorry if this is already addressed in another issue or worse yet the documentation, but I would love a way to do really custom profiling where I profile between two specific points in not-necessarily-synchronous code. For example,

// I guess I'll have to assume `c` is in an `Arc` or something

events.on("I haven't actually written an event emitter this is just an example", |_data| {
    c.finish("AsyncBench");
});

c.begin("AsyncBench");
events.emit("I haven't actually written an event emitter this is just an example", 5);

Is something like this supported, or will it ever be?

@bheisler
Copy link
Owner

Hey, thanks for trying Criterion.rs, and thanks for the suggestion!

This definitely doesn't exist now. Will it ever? Hard to say, really. I'm planning to open things up more for custom measurements in 0.3.0, so it might be possible to implement something like this in a third-party crate eventually. It doesn't seem like it would be a common-enough use case to belong inside Criterion.rs itself. On the other hand, whenever async/await support lands, it might be more useful to be able to benchmark systems involving asynchronous tasks.

I'll leave this open as a wish-list item for now and see what the future brings.

@bheisler bheisler added the Bigger Project A large project, probably involving major internal changes as well as new API surface label Feb 2, 2019
@spacemeowx2
Copy link

async fn is stable now. any new plans?

@bheisler
Copy link
Owner

async fn is not really relevant here; the request was to be able to insert markers at arbitrary points in the code and benchmark the time between them.

If you want to benchmark async functions, I would recommend running them to completion using futures::executor::block_on inside the benchmark as long as they don't require any network traffic to external systems (and if they do, it probably doesn't make sense to benchmark them anyway).

@rivertam
Copy link
Author

rivertam commented Dec 2, 2019

@bheisler That's a good point. You could convert my earlier example into valid code by using a one-shot channel future and then blocking on it.

@GopherJ
Copy link

GopherJ commented Apr 15, 2020

@bheisler I doubt if futures::executor::block_on can get the real numbers because block_on is a little be heavy and maybe we should reuse the same async runtime?

See also: #363 #403

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bigger Project A large project, probably involving major internal changes as well as new API surface Enhancement
Projects
None yet
Development

No branches or pull requests

4 participants