pub struct Index { /* private fields */ }Implementations§
Source§impl Index
impl Index
pub const fn version(&self) -> u32
Sourcepub fn entries(&self) -> &[IndexEntry]
pub fn entries(&self) -> &[IndexEntry]
Examples found in repository?
examples/benchmark_storage.rs (line 35)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12 let args = env::args().skip(1).collect::<Vec<_>>();
13 let path = args.first().map_or(".", String::as_str);
14 let iterations = args
15 .get(1)
16 .map(|value| value.parse())
17 .transpose()?
18 .unwrap_or(50);
19 let repository = Repository::open(path)?;
20 let head = repository.resolve("HEAD")?;
21
22 let expected_objects = git_object_ids(path)?;
23 let actual_objects = repository
24 .bitmap_reachable(head)?
25 .ok_or("repository has no reachability bitmap")?
26 .into_iter()
27 .map(|id| id.to_string())
28 .collect::<BTreeSet<_>>();
29 if actual_objects != expected_objects {
30 return Err("bitmap reachability differs from git rev-list --objects".into());
31 }
32 let expected_paths = git_paths(path)?;
33 let actual_paths = repository
34 .index()?
35 .entries()
36 .iter()
37 .map(|entry| entry.path.clone())
38 .collect::<Vec<_>>();
39 if actual_paths != expected_paths {
40 return Err("index paths differ from git ls-files".into());
41 }
42 let expected_status = git_status(path)?;
43 let actual_status = repository.status()?;
44 if !expected_status.is_empty() || !actual_status.is_empty() {
45 return Err(format!(
46 "status benchmark requires a clean tracked worktree (git={} bytes, weavatrix={actual_status:?})",
47 expected_status.len()
48 )
49 .into());
50 }
51
52 println!("operation,engine,p50_ms,p95_ms,items");
53 row(
54 "reachability",
55 "weavatrix-git",
56 &measure(iterations, || {
57 repository
58 .bitmap_reachable(head)
59 .map(|value| value.map_or(0, |ids| ids.len()))
60 })?,
61 actual_objects.len(),
62 );
63 row(
64 "reachability",
65 "git.exe",
66 &measure(iterations, || git_object_ids(path).map(|ids| ids.len()))?,
67 expected_objects.len(),
68 );
69 row(
70 "index",
71 "weavatrix-git",
72 &measure(iterations, || {
73 repository.index().map(|index| index.entries().len())
74 })?,
75 actual_paths.len(),
76 );
77 row(
78 "index",
79 "git.exe",
80 &measure(iterations, || git_paths(path).map(|paths| paths.len()))?,
81 expected_paths.len(),
82 );
83 row(
84 "tracked-status",
85 "weavatrix-git",
86 &measure(iterations, || {
87 repository.status().map(|entries| entries.len())
88 })?,
89 0,
90 );
91 row(
92 "tracked-status",
93 "git.exe",
94 &measure(iterations, || git_status(path).map(|entries| entries.len()))?,
95 0,
96 );
97 row(
98 "cached-commit",
99 "weavatrix-git",
100 &measure(iterations, || repository.commit(head).map(|_| 1))?,
101 1,
102 );
103 row(
104 "cached-commit",
105 "git.exe",
106 &measure(iterations, || git_exists(path, &head.to_string()))?,
107 1,
108 );
109 Ok(())
110}Trait Implementations§
impl Eq for Index
impl StructuralPartialEq for Index
Auto Trait Implementations§
impl Freeze for Index
impl RefUnwindSafe for Index
impl Send for Index
impl Sync for Index
impl Unpin for Index
impl UnsafeUnpin for Index
impl UnwindSafe for Index
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more