Skip to content

Commit

Permalink
add benchmarking for get_first_emoji
Browse files Browse the repository at this point in the history
  • Loading branch information
farooqkz committed May 28, 2024
1 parent 19b18d1 commit dc5b938
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion benches/my_benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use deltachat_message_parser::parser::{
parse_desktop_set, parse_markdown_text, parse_only_text, LinkDestination,
parse_desktop_set,
parse_markdown_text,
parse_only_text,
LinkDestination,
is_emoji::get_first_emoji,
};

pub fn criterion_benchmark(c: &mut Criterion) {
let testdata = include_str!("testdata.md");
let lorem_ipsum_txt = include_str!("lorem_ipsum.txt");
let r10s_update_message = include_str!("r10s_update_message.txt");
let links = include_str!("moar_links.txt");
let emojies = vec![
"not an emoji",
"\u{3299}\u{3300}",
"🟠",
"",
"🟠y",
"🍏",
"lorem",
"😀",
];

c.bench_function("only_text_lorem_ipsum.txt", |b| {
b.iter(|| parse_only_text(black_box(lorem_ipsum_txt)))
Expand Down Expand Up @@ -42,6 +56,9 @@ pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("parse_link_moar_links.txt", |b| {
b.iter(|| LinkDestination::parse(black_box(links)))
});
c.bench_function("emoji", |b| {
b.iter(|| emojies.iter().map(|s| get_first_emoji(black_box(s))))
});
}

criterion_group!(benches, criterion_benchmark);
Expand Down

0 comments on commit dc5b938

Please sign in to comment.