mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
28 lines
770 B
Rust
28 lines
770 B
Rust
use std::path::PathBuf;
|
|
|
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
|
use deltachat::accounts::Accounts;
|
|
use tempfile::tempdir;
|
|
|
|
async fn create_accounts(n: u32) {
|
|
let dir = tempdir().unwrap();
|
|
let p: PathBuf = dir.path().join("accounts");
|
|
|
|
let mut accounts = Accounts::new(p.clone()).await.unwrap();
|
|
|
|
for expected_id in 2..n {
|
|
let id = accounts.add_account().await.unwrap();
|
|
assert_eq!(id, expected_id);
|
|
}
|
|
}
|
|
|
|
fn criterion_benchmark(c: &mut Criterion) {
|
|
c.bench_function("create 1 account", |b| {
|
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
|
b.to_async(&rt).iter(|| create_accounts(black_box(1)))
|
|
});
|
|
}
|
|
|
|
criterion_group!(benches, criterion_benchmark);
|
|
criterion_main!(benches);
|