-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add simple parsing benchmark * Add additional benchmarks with larger input sizes
- Loading branch information
1 parent
c20b6e0
commit e83c214
Showing
6 changed files
with
248 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use std::fs; | ||
|
||
use bevy_mod_bbcode::parser::parse_bbcode; | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
|
||
pub fn small_raw_text(c: &mut Criterion) { | ||
c.bench_function("small raw text", |b| { | ||
b.iter(|| { | ||
parse_bbcode(black_box( | ||
"A simple small text string with just normal characters", | ||
)) | ||
}) | ||
}); | ||
} | ||
|
||
pub fn small_text_with_simple_formatting(c: &mut Criterion) { | ||
c.bench_function("small text with simple formatting", |b| { | ||
b.iter(|| { | ||
parse_bbcode(black_box( | ||
"A simple text with [b]bold[/b] and [i]italic[i] elements", | ||
)) | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group!( | ||
benches_small, | ||
small_raw_text, | ||
small_text_with_simple_formatting | ||
); | ||
|
||
pub fn large_raw_text(c: &mut Criterion) { | ||
let input = &fs::read_to_string("benches/input/sample_5000_raw.bbcode").unwrap(); | ||
|
||
c.bench_function("large raw text", |b| { | ||
b.iter(|| parse_bbcode(black_box(input))) | ||
}); | ||
} | ||
|
||
pub fn large_text_with_simple_formatting(c: &mut Criterion) { | ||
let input = &fs::read_to_string("benches/input/sample_5000_simple.bbcode").unwrap(); | ||
|
||
c.bench_function("large text with simple formatting", |b| { | ||
b.iter(|| parse_bbcode(black_box(input))) | ||
}); | ||
} | ||
|
||
criterion_group!( | ||
benches_large, | ||
large_raw_text, | ||
large_text_with_simple_formatting | ||
); | ||
|
||
criterion_main!(benches_small, benches_large); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub(crate) mod bbcode; | ||
pub(crate) mod bevy; | ||
|
||
pub use bbcode::*; | ||
pub use bevy::*; |