Skip to content

Commit

Permalink
add more benches
Browse files Browse the repository at this point in the history
  • Loading branch information
noib3 committed Nov 12, 2023
1 parent 6dee8bb commit 9239eec
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 4 deletions.
109 changes: 107 additions & 2 deletions benches/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ fn bench<'a, M, C>(
});
}

const MEDIUM_TEXT: &str =
"Far far away, behind the word mountains, far from the countries Vokalia \
and Consonantia, there live the blind texts. Separated they live in \
Bookmarksgrove right at the coast of the Semantics, a large.";

const LONG_TEXT: &str =
"Far far away, behind the word mountains, far from the countries Vokalia \
and Consonantia, there live the blind texts. Separated they live in \
Bookmarksgrove right at the coast of the Semantics, a large language \
ocean. A small river named Duden flows by their place and supplies it \
with the necessary regelialia. It is a paradisematic country, in which \
roasted parts of sentences fly into your mouth. Even the all-powerful \
Pointing has no control about the blind texts it is an almost \
unorthographic life";

// TODO: docs
pub fn short<M: Metric>(
metric: M,
Expand All @@ -113,8 +128,98 @@ pub fn short<M: Metric>(
M: Metric,
{
for_all_cases_and_ranges(metric, "short", suffix, |metric, id| {
let query = "jelly";
let candidates = core::iter::once("jellyfish");
let query = "paradise";
let candidates = core::iter::once("paradisematic");
bench(&mut group, id, metric, query, candidates);
})
}

// TODO: docs
pub fn medium_start<M: Metric>(
metric: M,
suffix: Option<&str>,
mut group: BenchmarkGroup<WallTime>,
) where
M: Metric,
{
for_all_cases_and_ranges(metric, "medium_start", suffix, |metric, id| {
let query = "away";
let candidates = core::iter::once(MEDIUM_TEXT);
bench(&mut group, id, metric, query, candidates);
})
}

// TODO: docs
pub fn medium_middle<M: Metric>(
metric: M,
suffix: Option<&str>,
mut group: BenchmarkGroup<WallTime>,
) where
M: Metric,
{
for_all_cases_and_ranges(metric, "medium_middle", suffix, |metric, id| {
let query = "blind";
let candidates = core::iter::once(MEDIUM_TEXT);
bench(&mut group, id, metric, query, candidates);
})
}

// TODO: docs
pub fn medium_end<M: Metric>(
metric: M,
suffix: Option<&str>,
mut group: BenchmarkGroup<WallTime>,
) where
M: Metric,
{
for_all_cases_and_ranges(metric, "medium_end", suffix, |metric, id| {
let query = "Semantics";
let candidates = core::iter::once(MEDIUM_TEXT);
bench(&mut group, id, metric, query, candidates);
})
}

// TODO: docs
pub fn long_start<M: Metric>(
metric: M,
suffix: Option<&str>,
mut group: BenchmarkGroup<WallTime>,
) where
M: Metric,
{
for_all_cases_and_ranges(metric, "long_start", suffix, |metric, id| {
let query = "mountains";
let candidates = core::iter::once(LONG_TEXT);
bench(&mut group, id, metric, query, candidates);
})
}

// TODO: docs
pub fn long_middle<M: Metric>(
metric: M,
suffix: Option<&str>,
mut group: BenchmarkGroup<WallTime>,
) where
M: Metric,
{
for_all_cases_and_ranges(metric, "long_middle", suffix, |metric, id| {
let query = "Duden";
let candidates = core::iter::once(LONG_TEXT);
bench(&mut group, id, metric, query, candidates);
})
}

// TODO: docs
pub fn long_end<M: Metric>(
metric: M,
suffix: Option<&str>,
mut group: BenchmarkGroup<WallTime>,
) where
M: Metric,
{
for_all_cases_and_ranges(metric, "long_end", suffix, |metric, id| {
let query = "unorthographic";
let candidates = core::iter::once(LONG_TEXT);
bench(&mut group, id, metric, query, candidates);
})
}
35 changes: 34 additions & 1 deletion benches/fzf_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,38 @@ fn short(c: &mut Criterion) {
bench::short(FzfV1::new(), None, group(c));
}

criterion_group!(benches, short);
fn medium_start(c: &mut Criterion) {
bench::medium_start(FzfV1::new(), None, group(c));
}

fn medium_middle(c: &mut Criterion) {
bench::medium_middle(FzfV1::new(), None, group(c));
}

fn medium_end(c: &mut Criterion) {
bench::medium_end(FzfV1::new(), None, group(c));
}

fn long_start(c: &mut Criterion) {
bench::long_start(FzfV1::new(), None, group(c));
}

fn long_middle(c: &mut Criterion) {
bench::long_middle(FzfV1::new(), None, group(c));
}

fn long_end(c: &mut Criterion) {
bench::long_end(FzfV1::new(), None, group(c));
}

criterion_group!(
benches,
short,
medium_start,
medium_middle,
medium_end,
long_start,
long_middle,
long_end,
);
criterion_main!(benches);
35 changes: 34 additions & 1 deletion benches/fzf_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,38 @@ fn short(c: &mut Criterion) {
bench::short(FzfV2::new(), None, group(c));
}

criterion_group!(benches, short);
fn medium_start(c: &mut Criterion) {
bench::medium_start(FzfV2::new(), None, group(c));
}

fn medium_middle(c: &mut Criterion) {
bench::medium_middle(FzfV2::new(), None, group(c));
}

fn medium_end(c: &mut Criterion) {
bench::medium_end(FzfV2::new(), None, group(c));
}

fn long_start(c: &mut Criterion) {
bench::long_start(FzfV2::new(), None, group(c));
}

fn long_middle(c: &mut Criterion) {
bench::long_middle(FzfV2::new(), None, group(c));
}

fn long_end(c: &mut Criterion) {
bench::long_end(FzfV2::new(), None, group(c));
}

criterion_group!(
benches,
short,
medium_start,
medium_middle,
medium_end,
long_start,
long_middle,
long_end,
);
criterion_main!(benches);

0 comments on commit 9239eec

Please sign in to comment.