mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
This allows account manager to construct a single event channel and inject it into all created contexts instead of aggregating events from separate event emitters.
30 lines
1.1 KiB
Rust
30 lines
1.1 KiB
Rust
use criterion::async_executor::AsyncStdExecutor;
|
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
|
|
|
use deltachat::chatlist::Chatlist;
|
|
use deltachat::context::Context;
|
|
use deltachat::Events;
|
|
|
|
async fn get_chat_list_benchmark(context: &Context) {
|
|
Chatlist::try_load(context, 0, None, None).await.unwrap();
|
|
}
|
|
|
|
fn criterion_benchmark(c: &mut Criterion) {
|
|
// To enable this benchmark, set `DELTACHAT_BENCHMARK_DATABASE` to some large database with many
|
|
// messages, such as your primary account.
|
|
if let Ok(path) = std::env::var("DELTACHAT_BENCHMARK_DATABASE") {
|
|
let context = async_std::task::block_on(async {
|
|
Context::new(path.into(), 100, Events::new()).await.unwrap()
|
|
});
|
|
c.bench_function("chatlist:try_load (Get Chatlist)", |b| {
|
|
b.to_async(AsyncStdExecutor)
|
|
.iter(|| get_chat_list_benchmark(black_box(&context)))
|
|
});
|
|
} else {
|
|
println!("env var not set: DELTACHAT_BENCHMARK_DATABASE");
|
|
}
|
|
}
|
|
|
|
criterion_group!(benches, criterion_benchmark);
|
|
criterion_main!(benches);
|