Skip to content

Function tokenizer::preprocess 3x faster #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 18, 2014
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Benchmark for preprocess function
  • Loading branch information
ayosec committed Dec 18, 2014
commit ea6c1b721a88482354d8236f6ad25aac41e60e57
17 changes: 15 additions & 2 deletions src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,21 @@ fn preprocess(input: &str) -> String {
#[test]
fn test_preprocess() {
assert!("" == preprocess("").as_slice());
assert!("Lorem\n\t\u{FFFD}ipusm\ndoror\u{FFFD}\n" ==
preprocess("Lorem\r\n\t\x00ipusm\ndoror\u{FFFD}\r").as_slice());
assert!("Lorem\n\n\t\u{FFFD}ipusm\ndoror\u{FFFD}á\n" ==
preprocess("Lorem\r\n\n\t\x00ipusm\ndoror\u{FFFD}á\r").as_slice());
}

#[cfg(test)]
mod bench_preprocess {
extern crate test;

#[bench]
fn bench_preprocess(b: &mut test::Bencher) {
let source = "Lorem\n\t\u{FFFD}ipusm\ndoror\u{FFFD}á\n";
b.iter(|| {
let _ = super::preprocess(source);
});
}
}


Expand Down