From cd7e7e8f2ecd39f4992cc17c0b6d6b13cdfe9174 Mon Sep 17 00:00:00 2001 From: Farooq Karimi Zadeh Date: Thu, 30 May 2024 14:49:53 +0330 Subject: [PATCH] Add benchmarking for get_first_emoji (#73) * add benchmarking for get_first_emoji * add more emojies * better formatting * add more complex/composite emojis --------- Co-authored-by: Simon Laux --- benches/my_benchmark.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/benches/my_benchmark.rs b/benches/my_benchmark.rs index 13bedf5..9c4fbd0 100644 --- a/benches/my_benchmark.rs +++ b/benches/my_benchmark.rs @@ -1,6 +1,7 @@ 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) { @@ -8,6 +9,28 @@ pub fn criterion_benchmark(c: &mut Criterion) { 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))) @@ -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);