Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
apparebit committed Nov 13, 2024
1 parent c9948af commit 1c8cbfc
Showing 1 changed file with 21 additions and 41 deletions.
62 changes: 21 additions & 41 deletions benches/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,32 @@ use prettypretty::theme;

pub fn run_benchmarks(c: &mut Criterion) {
unsafe { terminal().connect() }.unwrap();

// Compare the query functions without the overhead of object creation.
let mut group = c.benchmark_group("theme-query");
group.sample_size(10);

group.bench_function(
"1-loop",
| b | {
b.iter_batched(
|| theme::prepare(false).expect("access to terminal"),
|(mut tty, mut scanner, mut theme)| {
theme::query1(&mut tty, &mut scanner, &mut theme)
},
BatchSize::PerIteration,
)
},
);

group.bench_function(
"2-loops",
| b | {
b.iter_batched(
|| theme::prepare(false).expect("access to terminal"),
|(mut tty, mut scanner, mut theme)| {
theme::query2(&mut tty, &mut scanner, &mut theme)
},
BatchSize::PerIteration,
)
},
);

group.bench_function(
"3-loops",
| b | {
b.iter_batched(
|| theme::prepare(false).expect("access to terminal"),
|(mut tty, mut scanner, mut theme)| {
theme::query3(&mut tty, &mut scanner, &mut theme)
},
BatchSize::PerIteration,
)
},
);
group.bench_function("1-loop", |b| {
b.iter_batched(
|| theme::prepare(false).expect("access to terminal"),
|(mut tty, mut scanner, mut theme)| theme::query1(&mut tty, &mut scanner, &mut theme),
BatchSize::PerIteration,
)
});
group.bench_function("2-loops", |b| {
b.iter_batched(
|| theme::prepare(false).expect("access to terminal"),
|(mut tty, mut scanner, mut theme)| theme::query2(&mut tty, &mut scanner, &mut theme),
BatchSize::PerIteration,
)
});
group.bench_function("3-loops", |b| {
b.iter_batched(
|| theme::prepare(false).expect("access to terminal"),
|(mut tty, mut scanner, mut theme)| theme::query3(&mut tty, &mut scanner, &mut theme),
BatchSize::PerIteration,
)
});

group.finish();

terminal().disconnect();
}

Expand Down

0 comments on commit 1c8cbfc

Please sign in to comment.