-
Notifications
You must be signed in to change notification settings - Fork 105
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
Implement basic performance benchmark #80
Comments
Yep, getting all manner of issues because criterion wants to pass a non-static ref along to a non-async function, so to invoke an async function I would need to to |
Update: I think I've figured out how to get this working. Here's what the code looks like right now. The key was manually creating the tokio runtime, and using fn criterion_benchmark(c: &mut Criterion) {
let mut rt = Runtime::new().unwrap();
let (mut pubs, mut subs) = rt.block_on(setup(4, 16));
c.bench_function("m pubs and n subs messaging", |b| {
b.iter(|| rt.block_on(f(&mut pubs, &mut subs)))
});
async fn f(pubs: &mut [PubSocket], subs: &mut [SubSocket]) {
// Send/Recv messages
}
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches); |
Continuation of the discussion in #77.
We need to implement a basic performance benchmark, to detect any major performance regressions. docs.rs/criterion seems like a good choice. However, Its proving a lot more difficult than expected to use criterion to benchmark async code - its not clear to me exactly how to do this - I can't for example pass the
&mut Criterion
through to the async task, because its notSend
The text was updated successfully, but these errors were encountered: