Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
update benches
Browse files Browse the repository at this point in the history
  • Loading branch information
tamuhey committed Apr 1, 2021
1 parent 29f8a02 commit bcf8a55
Showing 1 changed file with 44 additions and 5 deletions.
49 changes: 44 additions & 5 deletions benches/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use tokenizations;

fn bench_get_alignments(c: &mut Criterion) {
fn get_alignments(c: &mut Criterion) {
let mut group = c.benchmark_group("get_alignments");
let s = black_box(vec![
"asd",
"asdfasdf",
Expand All @@ -18,12 +19,50 @@ fn bench_get_alignments(c: &mut Criterion) {
"q2---0t",
"q --:あh4t0-q4t2",
]);
let s = s.repeat(10);
let t = t.repeat(10);
c.bench_function("get_alignments", |b| {
let u = black_box(vec![
"zzz",
"zzzzzz",
"ppppp",
"pppp",
"ppppppp",
"ppppppppppppppp",
]);

// short
group.bench_function("handmade short", |b| {
b.iter(|| tokenizations::get_alignments(&s, &t))
});

// long
let n = black_box(100);
let s_long = s.repeat(n);
let t_long = t.repeat(n);
let u_long = u.repeat(n);
group.bench_function("handmade long", |b| {
b.iter(|| tokenizations::get_alignments(&s_long, &t_long))
});

// identical short
group.bench_function("identical short", |b| {
b.iter(|| tokenizations::get_alignments(&s, &s))
});

// identical long
group.bench_function("identical short", |b| {
b.iter(|| tokenizations::get_alignments(&s_long, &s_long))
});

// completely different short
group.bench_function("completery different short", |b| {
b.iter(|| tokenizations::get_alignments(&s, &u))
});

// completely different long
group.bench_function("completery different long", |b| {
b.iter(|| tokenizations::get_alignments(&s_long, &u_long))
});
group.finish()
}

criterion_group!(benches, bench_get_alignments);
criterion_group!(benches, get_alignments);
criterion_main!(benches);

0 comments on commit bcf8a55

Please sign in to comment.