Skip to content

Commit

Permalink
Add benchmarking for get_first_emoji (#73)
Browse files Browse the repository at this point in the history
* add benchmarking for get_first_emoji

* add more emojies

* better formatting

* add more complex/composite emojis

---------

Co-authored-by: Simon Laux <[email protected]>
  • Loading branch information
farooqkz and Simon-Laux authored May 30, 2024
1 parent 967dca4 commit cd7e7e8
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion benches/my_benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use deltachat_message_parser::parser::{
parse_desktop_set, parse_markdown_text, parse_only_text, LinkDestination,
is_emoji::get_first_emoji, parse_desktop_set, parse_markdown_text, parse_only_text,
LinkDestination,
};

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",
"😀",
"\u{2755}",
"\u{2655}",
"\u{2000}",
"\u{25aa}",
"\u{2934}",
"\u{2195}",
"🆎",
"🎓",
"🟰",
"👨‍👩‍👧‍👧",
"👨‍👩‍👧‍👧👨‍👩‍👧‍👧👨‍👩‍👧‍👧👨‍👩‍👧‍👧",
"👸🏾",
];

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 +65,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 cd7e7e8

Please sign in to comment.