mirror of
https://github.com/lotabout/skim.git
synced 2026-09-10 07:16:23 -04:00
* feat: bump frizbee to 0.10.0, thread local matcher * feat: use frizbee on all architectures * feat: use frizbee feature * refactor: simplify frizbee config mutation * docs: simplify frizbee thread local comment * fixup! feat: use frizbee feature * fixup! feat: use frizbee feature
68 lines
1.7 KiB
Rust
68 lines
1.7 KiB
Rust
#![allow(missing_docs, clippy::pedantic)]
|
|
|
|
use gungraun::{library_benchmark, library_benchmark_group, main};
|
|
use std::fs;
|
|
use std::hint::black_box;
|
|
|
|
use skim::CaseMatching;
|
|
use skim::fuzzy_matcher::FuzzyMatcher;
|
|
use skim::fuzzy_matcher::arinae::ArinaeMatcher;
|
|
use skim::fuzzy_matcher::frizbee::FrizbeeMatcher;
|
|
use skim::prelude::SkimMatcherV2;
|
|
|
|
fn load_lines() -> Vec<String> {
|
|
let data = fs::read_to_string("benches/fixtures/1M.txt").expect("1M.txt missing");
|
|
data.lines().map(|l| l.to_string()).collect()
|
|
}
|
|
|
|
#[inline(always)]
|
|
fn bench_matcher(m: impl FuzzyMatcher, lines: Vec<String>) -> u64 {
|
|
let mut count = 0u64;
|
|
for line in &lines {
|
|
if m.fuzzy_indices(line, "test").is_some() {
|
|
count += 1;
|
|
}
|
|
}
|
|
count
|
|
}
|
|
|
|
#[library_benchmark]
|
|
fn skim_v2() -> u64 {
|
|
bench_matcher(SkimMatcherV2::default().smart_case(), black_box(load_lines()))
|
|
}
|
|
#[library_benchmark]
|
|
fn frizbee() -> u64 {
|
|
bench_matcher(
|
|
FrizbeeMatcher::default().case(CaseMatching::Smart).max_typos(Some(0)),
|
|
black_box(load_lines()),
|
|
)
|
|
}
|
|
#[library_benchmark]
|
|
fn frizbee_typos() -> u64 {
|
|
bench_matcher(
|
|
FrizbeeMatcher::default().case(CaseMatching::Smart).max_typos(Some(1)),
|
|
black_box(load_lines()),
|
|
)
|
|
}
|
|
#[library_benchmark]
|
|
fn arinae() -> u64 {
|
|
bench_matcher(
|
|
ArinaeMatcher::new(CaseMatching::Smart, false, false),
|
|
black_box(load_lines()),
|
|
)
|
|
}
|
|
#[library_benchmark]
|
|
fn arinae_typos() -> u64 {
|
|
bench_matcher(
|
|
ArinaeMatcher::new(CaseMatching::Smart, true, false),
|
|
black_box(load_lines()),
|
|
)
|
|
}
|
|
|
|
library_benchmark_group!(
|
|
name = benches,
|
|
benchmarks = [skim_v2, frizbee, frizbee_typos, arinae, arinae_typos]
|
|
);
|
|
|
|
main!(library_benchmark_groups = benches);
|