clean up rebase

This commit is contained in:
Septias
2022-12-06 19:14:40 +01:00
parent d14ae03356
commit 299ac4b39e
10 changed files with 72 additions and 190 deletions

View File

@@ -1,8 +1,8 @@
use criterion::async_executor::AsyncStdExecutor;
use criterion::{criterion_group, criterion_main, Criterion};
use deltachat::context::Context;
use deltachat::{info, Event, EventType};
use deltachat::stock_str::StockStrings;
use deltachat::{info, Event, EventType, Events};
use tempfile::tempdir;
async fn send_events_benchmark(context: &Context) {
@@ -29,11 +29,17 @@ fn criterion_benchmark(c: &mut Criterion) {
let dir = tempdir().unwrap();
let dbfile = dir.path().join("db.sqlite");
let id = 100;
let context =
async_std::task::block_on(async { Context::new(dbfile.into(), id).await.unwrap() });
let rt = tokio::runtime::Runtime::new().unwrap();
let context = rt.block_on(async {
Context::new(&dbfile, id, Events::new(), StockStrings::new())
.await
.expect("failed to create context")
});
let executor = tokio::runtime::Runtime::new().unwrap();
c.bench_function("Sending 1000 events", |b| {
b.to_async(AsyncStdExecutor)
b.to_async(&executor)
.iter(|| send_events_benchmark(&context))
});
}