History

[hours-demo] Proper logic for flags; performance stats for deduplication

Sebastian Thiel committed 5 years ago

Commit d5ac96d1 parent f6ee0f21 file · +13 −4Browse files

Unified · Split

examples/hours/src/main.rs+13−4
@@ -50,8 +50,8 @@ struct Opts { · 49 unmodified lines
5050 /// Omit personally identifiable information, leaving only the summary.
5151 #[clap(short = 'p', long)]
5252 omit_pii: bool,
53− /// Unify identities by name and email
54− #[clap(short = 'i', long)]
53+ /// Unify identities by name and email.
54+ #[clap(short = 'i', long, conflicts_with = "omit-pii")]
5555 unify_identities: bool,
5656 }
5757
@@ -146,7 +146,16 @@ fn main() -> anyhow::Result<()> { · 88 unmodified lines
146146 }
147147
148148 let mut results_by_hours = if opts.unify_identities {
149− deduplicate_identities(&results_by_hours)
149+ let start = Instant::now();
150+ let res = deduplicate_identities(&results_by_hours);
151+ let elapsed = start.elapsed();
152+ eprintln!(
153+ "Deduplicated {} contributors in {:.02}s by name and email, now {}",
154+ results_by_hours.len(),
155+ elapsed.as_secs_f32(),
156+ res.len()
157+ );
158+ res
150159 } else {
151160 results_by_hours
152161 .iter()
@@ -211,7 +220,7 @@ fn estimate_hours(commits: &[git_object::mutable::Signature]) -> WorkByEmail { · 58 unmodified lines
211220 }
212221
213222 fn deduplicate_identities(persons: &[WorkByEmail]) -> Vec<WorkByPerson<'_>> {
214− let mut out = Vec::<WorkByPerson>::new();
223+ let mut out = Vec::<WorkByPerson>::with_capacity(persons.len());
215224 for person_by_email in persons {
216225 match out
217226 .iter_mut()

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t