Skip to main content

Index

Struct Index 

Source
pub struct Index { /* private fields */ }

Implementations§

Source§

impl Index

Source

pub const fn version(&self) -> u32

Source

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§

Source§

impl Clone for Index

Source§

fn clone(&self) -> Index

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Index

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Index

Source§

impl PartialEq for Index

Source§

fn eq(&self, other: &Index) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.