Skip to content

Commit ea6c1b7

Browse files
committed
Benchmark for preprocess function
1 parent fd6c871 commit ea6c1b7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/tokenizer.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,21 @@ fn preprocess(input: &str) -> String {
4242
#[test]
4343
fn test_preprocess() {
4444
assert!("" == preprocess("").as_slice());
45-
assert!("Lorem\n\t\u{FFFD}ipusm\ndoror\u{FFFD}\n" ==
46-
preprocess("Lorem\r\n\t\x00ipusm\ndoror\u{FFFD}\r").as_slice());
45+
assert!("Lorem\n\n\t\u{FFFD}ipusm\ndoror\u{FFFD}á\n" ==
46+
preprocess("Lorem\r\n\n\t\x00ipusm\ndoror\u{FFFD}á\r").as_slice());
47+
}
48+
49+
#[cfg(test)]
50+
mod bench_preprocess {
51+
extern crate test;
52+
53+
#[bench]
54+
fn bench_preprocess(b: &mut test::Bencher) {
55+
let source = "Lorem\n\t\u{FFFD}ipusm\ndoror\u{FFFD}á\n";
56+
b.iter(|| {
57+
let _ = super::preprocess(source);
58+
});
59+
}
4760
}
4861

4962

0 commit comments

Comments
 (0)