Skip to content

Commit e9ac514

Browse files
committed
refactor
* use `gix_date::Time` instead of buffer-based time. ``` ❯ ein t hours 08:25:34 traverse commit graph done 1.3M commits in 9.12s (143.6K commits/s) 08:25:34 estimate-hours Extracted and organized data from 1309152 commits in 7.67ms (170684736 commits/s) total hours: 1243723.88 total 8h days: 155465.48 total commits = 1309152 total authors: 34641 total unique authors: 26510 (23.47% duplication) linux ( master) +408 -798 [!⇣14583] took 9s ❯ /Users/byron/dev/github.com/GitoxideLabs/gitoxide/target/release/ein t hours 08:26:42 traverse commit graph done 1.3M commits in 7.84s (167.1K commits/s) 08:26:43 estimate-hours Extracted and organized data from 1309152 commits in 39.432084ms (33200174 commits/s) total hours: 1243723.88 total 8h days: 155465.48 total commits = 1309152 total authors: 34641 total unique authors: 26510 (23.47% duplication) linux ( master) +408 -798 [!⇣14583] took 8s ❯ /Users/byron/dev/github.com/GitoxideLabs/gitoxide/target/release/ein t hours 08:32:59 traverse commit graph done 1.3M commits in 7.73s (169.4K commits/s) 08:32:59 estimate-hours Extracted and organized data from 1309152 commits in 5.423541ms (241383248 commits/s) total hours: 1243723.88 total 8h days: 155465.48 total commits = 1309152 total authors: 34641 total unique authors: 26510 (23.47% duplication) ```
1 parent 70097c0 commit e9ac514

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

gitoxide-core/src/hours/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const MINUTES_PER_HOUR: f32 = 60.0;
1717
pub const HOURS_PER_WORKDAY: f32 = 8.0;
1818

1919
pub fn estimate_hours(
20-
commits: &[(u32, gix::actor::SignatureRef<'static>)],
20+
commits: &[(u32, super::SignatureRef<'static>)],
2121
stats: &[(u32, FileStats, LineStats)],
2222
) -> WorkByEmail {
2323
assert!(!commits.is_empty());

gitoxide-core/src/hours/mod.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::{collections::BTreeSet, io, path::Path, time::Instant};
22

33
use anyhow::bail;
44
use gix::{
5-
actor,
65
bstr::{BStr, ByteSlice},
76
prelude::*,
87
progress, Count, NestedProgress, Progress,
@@ -27,6 +26,18 @@ pub struct Context<W> {
2726
pub out: W,
2827
}
2928

29+
pub struct SignatureRef<'a> {
30+
name: &'a BStr,
31+
email: &'a BStr,
32+
time: gix_date::Time,
33+
}
34+
35+
impl SignatureRef<'_> {
36+
fn seconds(&self) -> gix_date::SecondsSinceUnixEpoch {
37+
self.time.seconds
38+
}
39+
}
40+
3041
/// Estimate the hours it takes to produce the content of the repository in `_working_dir_`, with `_refname_` for
3142
/// the start of the commit graph traversal.
3243
///
@@ -82,10 +93,15 @@ where
8293
};
8394
let name = string_ref(author.name.as_ref());
8495
let email = string_ref(author.email.as_ref());
85-
let mut buf = Vec::with_capacity(64);
86-
let time = string_ref(author.time.to_ref(&mut buf));
8796

88-
out.push((commit_idx, actor::SignatureRef { name, email, time }));
97+
out.push((
98+
commit_idx,
99+
SignatureRef {
100+
name,
101+
email,
102+
time: author.time,
103+
},
104+
));
89105
}
90106
}
91107
out.shrink_to_fit();

0 commit comments

Comments
 (0)