Skip to content

Commit

Permalink
test(perf): Bench more parsing cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed Page committed Apr 21, 2021
1 parent 1f4c587 commit 676926c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion benches/tokenize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,31 @@ fn bench_tokenize(c: &mut Criterion) {
let mut group = c.benchmark_group("tokenize");
for (name, sample) in data::DATA {
let len = sample.len();
group.bench_with_input(BenchmarkId::new("ident", name), &len, |b, _| {
group.bench_with_input(BenchmarkId::new("ident(bytes)", name), &len, |b, _| {
let parser = typos::tokens::Tokenizer::new();
b.iter(|| parser.parse_bytes(sample.as_bytes()).last());
});
group.bench_with_input(BenchmarkId::new("ident(str)", name), &len, |b, _| {
let parser = typos::tokens::Tokenizer::new();
b.iter(|| parser.parse_str(sample).last());
});
group.bench_with_input(BenchmarkId::new("words", name), &len, |b, _| {
let symbol = typos::tokens::Identifier::new_unchecked(sample, 0);
b.iter(|| symbol.split().last());
});
group.bench_with_input(
BenchmarkId::new("ident(bytes)+words", name),
&len,
|b, _| {
let parser = typos::tokens::Tokenizer::new();
b.iter(|| {
parser
.parse_bytes(sample.as_bytes())
.flat_map(|i| i.split())
.last()
});
},
);
}
group.finish();
}
Expand Down

0 comments on commit 676926c

Please sign in to comment.