Files
zed/crates/project_panel/benches/sorting.rs
Smit Barmase 998fece3af project_panel: Add ability to hide hidden files (#39843)
Closes #5185

Release Notes:

- Added an option to hide hidden files in the project panel by setting
`hide_hidden` in the project panel settings.

---------

Co-authored-by: Gaauwe Rombouts <gromdroid@gmail.com>
Co-authored-by: Gaauwe Rombouts <mail@grombouts.nl>
2025-10-12 18:31:55 +05:30

56 lines
1.8 KiB
Rust

use criterion::{Criterion, criterion_group, criterion_main};
use project::{Entry, EntryKind, GitEntry, ProjectEntryId};
use project_panel::par_sort_worktree_entries;
use std::sync::Arc;
use util::rel_path::RelPath;
fn load_linux_repo_snapshot() -> Vec<GitEntry> {
let file = std::fs::read_to_string(
"/Users/hiro/Projects/zed/crates/project_panel/benches/linux_repo_snapshot.txt",
)
.expect("Failed to read file");
file.lines()
.filter_map(|line| {
let kind = match line.chars().next() {
Some('f') => EntryKind::File,
Some('d') => EntryKind::Dir,
_ => return None,
};
let entry = Entry {
kind,
path: Arc::from(RelPath::unix(&(line.trim_end()[2..])).unwrap()),
id: ProjectEntryId::default(),
size: 0,
inode: 0,
mtime: None,
canonical_path: None,
is_ignored: false,
is_always_included: false,
is_external: false,
is_private: false,
is_hidden: false,
char_bag: Default::default(),
is_fifo: false,
};
Some(GitEntry {
entry,
git_summary: Default::default(),
})
})
.collect()
}
fn criterion_benchmark(c: &mut Criterion) {
let snapshot = load_linux_repo_snapshot();
c.bench_function("Sort linux worktree snapshot", |b| {
b.iter_batched(
|| snapshot.clone(),
|mut snapshot| par_sort_worktree_entries(&mut snapshot),
criterion::BatchSize::LargeInput,
);
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);