You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xplr/benches/navigation.rs

47 lines
1.3 KiB
Rust

use criterion::{criterion_group, criterion_main, Criterion};
use std::fs;
use xplr::*;
fn criterion_benchmark(c: &mut Criterion) {
let app = app::create()
.expect("failed to create app")
.change_directory(&"/tmp/xplr_bench".to_string())
.unwrap();
fs::create_dir_all("/tmp/xplr_bench").unwrap();
(1..10000).for_each(|i| {
fs::File::create(format!("/tmp/xplr_bench/{}", i)).unwrap();
});
c.bench_function("focus next item", |b| {
b.iter(|| {
app.clone()
.handle(&config::Action::Global(config::GlobalAction::FocusNextItem))
})
});
c.bench_function("focus previous item", |b| {
b.iter(|| {
app.clone().handle(&config::Action::Global(
config::GlobalAction::FocusPreviousItem,
))
})
});
c.bench_function("focus first item", |b| {
b.iter(|| {
app.clone()
.handle(&config::Action::Global(config::GlobalAction::FocusFirstItem))
})
});
c.bench_function("focus last item", |b| {
b.iter(|| {
app.clone()
.handle(&config::Action::Global(config::GlobalAction::FocusLastItem))
})
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);