mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 01:16:31 +03:00
Benchmark dc_receive_imf()
Don't count the account creation in the receive emails benchmark Use Criterion's async support See https://bheisler.github.io/criterion.rs/book/user_guide/benchmarking_async.html
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -847,11 +847,13 @@ version = "0.3.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10"
|
checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"async-std",
|
||||||
"atty",
|
"atty",
|
||||||
"cast",
|
"cast",
|
||||||
"clap",
|
"clap",
|
||||||
"criterion-plot",
|
"criterion-plot",
|
||||||
"csv",
|
"csv",
|
||||||
|
"futures",
|
||||||
"itertools",
|
"itertools",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ humansize = "1"
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
ansi_term = "0.12.0"
|
ansi_term = "0.12.0"
|
||||||
async-std = { version = "1", features = ["unstable", "attributes"] }
|
async-std = { version = "1", features = ["unstable", "attributes"] }
|
||||||
criterion = "0.3"
|
criterion = { version = "0.3.4", features = ["async_std"] }
|
||||||
futures-lite = "1.12"
|
futures-lite = "1.12"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
pretty_assertions = "1.0"
|
pretty_assertions = "1.0"
|
||||||
@@ -116,6 +116,10 @@ harness = false
|
|||||||
name = "search_msgs"
|
name = "search_msgs"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "receive_emails"
|
||||||
|
harness = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["vendored"]
|
default = ["vendored"]
|
||||||
internals = []
|
internals = []
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ async fn create_accounts(n: u32) {
|
|||||||
let dir = tempdir().unwrap();
|
let dir = tempdir().unwrap();
|
||||||
let p: PathBuf = dir.path().join("accounts").into();
|
let p: PathBuf = dir.path().join("accounts").into();
|
||||||
|
|
||||||
let accounts = Accounts::new("my_os".into(), p.clone()).await.unwrap();
|
let mut accounts = Accounts::new("my_os".into(), p.clone()).await.unwrap();
|
||||||
|
|
||||||
for expected_id in 2..n {
|
for expected_id in 2..n {
|
||||||
let id = accounts.add_account().await.unwrap();
|
let id = accounts.add_account().await.unwrap();
|
||||||
|
|||||||
121
benches/receive_emails.rs
Normal file
121
benches/receive_emails.rs
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
use std::convert::TryInto;
|
||||||
|
|
||||||
|
use async_std::task::block_on;
|
||||||
|
use criterion::{
|
||||||
|
async_executor::AsyncStdExecutor, black_box, criterion_group, criterion_main, BatchSize,
|
||||||
|
Criterion,
|
||||||
|
};
|
||||||
|
use deltachat::{config::Config, context::Context, dc_receive_imf::dc_receive_imf};
|
||||||
|
use tempfile::tempdir;
|
||||||
|
|
||||||
|
async fn recv_emails(context: Context, emails: &[&[u8]]) -> Context {
|
||||||
|
for (i, bytes) in emails.iter().enumerate() {
|
||||||
|
dc_receive_imf(
|
||||||
|
&context,
|
||||||
|
bytes,
|
||||||
|
"INBOX",
|
||||||
|
black_box(i.try_into().unwrap()),
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
context
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn recv_all_emails(context: Context) -> Context {
|
||||||
|
let emails = [
|
||||||
|
include_bytes!("../test-data/message/allinkl-quote.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/apple_cid_jpg.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/attach_filename_apostrophed_cont.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/attach_filename_apostrophed_cp1252.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/attach_filename_apostrophed.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/attach_filename_apostrophed_invalid.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/attach_filename_apostrophed_windows1251.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/attach_filename_combined.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/attach_filename_encoded_words_bad_delimiter.eml")
|
||||||
|
.as_ref(),
|
||||||
|
include_bytes!("../test-data/message/attach_filename_encoded_words_binary.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/attach_filename_encoded_words_cont.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/attach_filename_encoded_words.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/attach_filename_encoded_words_windows1251.eml")
|
||||||
|
.as_ref(),
|
||||||
|
include_bytes!("../test-data/message/attach_filename_simple.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/AutocryptSetupMessage.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/blockquote-tag.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/cp1252-html.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/gmail_ndn.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/gmail_ndn_group.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/gmx-forward.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/gmx_ndn.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/gmx-quote-body.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/gmx-quote.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/mail_attach_txt.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/mailinglist_dhl.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/mailinglist_dpd.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/mailinglist_ttline.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/mailinglist_with_mimepart_footer.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/mailinglist_with_mimepart_footer_signed.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/mailinglist_xing.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/mailinglist_xt_local_microsoft.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/mailinglist_xt_local_spiegel.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/mail_with_user_and_group_avatars.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/mail_with_user_avatar_deleted.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/mail_with_user_avatar.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/many_images_amazon_via_apple_mail.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/pdf_filename_continuation.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/pdf_filename_simple.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/posteo_ndn.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/protonmail-mixed-up.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/protonmail-repaired.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/quote_attach.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/subj_with_multimedia_msg.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/testrun_ndn_2.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/testrun_ndn.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/text_alt_html.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/text_alt_plain.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/text_alt_plain_html.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/text_html.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/text_plain_flowed.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/text_plain_iso88591.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/text_plain_unspecified.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/tiscali_ndn.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/videochat_invitation.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/wrong-html.eml").as_ref(),
|
||||||
|
include_bytes!("../test-data/message/yahoo_ndn.eml").as_ref(),
|
||||||
|
];
|
||||||
|
recv_emails(context, &emails).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn create_context() -> Context {
|
||||||
|
let dir = tempdir().unwrap();
|
||||||
|
let dbfile = dir.path().join("db.sqlite");
|
||||||
|
let id = 100;
|
||||||
|
let context = Context::new("FakeOS".into(), dbfile.into(), id)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
let addr = "alice@example.com";
|
||||||
|
context.set_config(Config::Addr, Some(addr)).await.unwrap();
|
||||||
|
context
|
||||||
|
.set_config(Config::ConfiguredAddr, Some(addr))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
context
|
||||||
|
.set_config(Config::Configured, Some("1"))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
context
|
||||||
|
}
|
||||||
|
|
||||||
|
fn criterion_benchmark(c: &mut Criterion) {
|
||||||
|
c.bench_function("Receive many messages", |b| {
|
||||||
|
b.to_async(AsyncStdExecutor).iter_batched(
|
||||||
|
|| block_on(create_context()),
|
||||||
|
|context| recv_all_emails(black_box(context)),
|
||||||
|
BatchSize::LargeInput,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
criterion_main!(benches);
|
||||||
66
deltachat-test-messages/src/lib.rs
Normal file
66
deltachat-test-messages/src/lib.rs
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
|
pub static ALL_TEST_MESSAGES: Lazy<[&[u8]; 56]> = Lazy::new(|| {
|
||||||
|
[
|
||||||
|
include_bytes!("../../test-data/message/allinkl-quote.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/apple_cid_jpg.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/attach_filename_apostrophed_cont.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/attach_filename_apostrophed_cp1252.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/attach_filename_apostrophed.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/attach_filename_apostrophed_invalid.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/attach_filename_apostrophed_windows1251.eml")
|
||||||
|
.as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/attach_filename_combined.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/attach_filename_encoded_words_bad_delimiter.eml")
|
||||||
|
.as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/attach_filename_encoded_words_binary.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/attach_filename_encoded_words_cont.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/attach_filename_encoded_words.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/attach_filename_encoded_words_windows1251.eml")
|
||||||
|
.as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/attach_filename_simple.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/AutocryptSetupMessage.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/blockquote-tag.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/cp1252-html.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/gmail_ndn.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/gmail_ndn_group.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/gmx-forward.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/gmx_ndn.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/gmx-quote-body.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/gmx-quote.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/mail_attach_txt.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/mailinglist_dhl.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/mailinglist_dpd.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/mailinglist_ttline.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/mailinglist_with_mimepart_footer.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/mailinglist_with_mimepart_footer_signed.eml")
|
||||||
|
.as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/mailinglist_xing.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/mailinglist_xt_local_microsoft.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/mailinglist_xt_local_spiegel.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/mail_with_user_and_group_avatars.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/mail_with_user_avatar_deleted.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/mail_with_user_avatar.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/many_images_amazon_via_apple_mail.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/pdf_filename_continuation.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/pdf_filename_simple.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/posteo_ndn.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/protonmail-mixed-up.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/protonmail-repaired.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/quote_attach.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/subj_with_multimedia_msg.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/testrun_ndn_2.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/testrun_ndn.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/text_alt_html.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/text_alt_plain.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/text_alt_plain_html.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/text_html.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/text_plain_flowed.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/text_plain_iso88591.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/text_plain_unspecified.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/tiscali_ndn.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/videochat_invitation.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/yahoo_ndn.eml").as_ref(),
|
||||||
|
include_bytes!("../../test-data/message/wrong-html.eml").as_ref(),
|
||||||
|
]
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user