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
50 /// Omit personally identifiable information, leaving only the summary.50 /// Omit personally identifiable information, leaving only the summary.
51 #[clap(short = 'p', long)]51 #[clap(short = 'p', long)]
52 omit_pii: bool,52 omit_pii: bool,
53 /// Unify identities by name and email53 /// Unify identities by name and email.
54 #[clap(short = 'i', long)]54 #[clap(short = 'i', long, conflicts_with = "omit-pii")]
55 unify_identities: bool,55 unify_identities: bool,
56}56}
57 57
@@ -146,7 +146,16 @@ fn main() -> anyhow::Result<()> { · 88 unmodified lines
146 }146 }
147 147
148 let mut results_by_hours = if opts.unify_identities {148 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
150 } else {159 } else {
151 results_by_hours160 results_by_hours
152 .iter()161 .iter()
@@ -211,7 +220,7 @@ fn estimate_hours(commits: &[git_object::mutable::Signature]) -> WorkByEmail { · 58 unmodified lines
211}220}
212 221
213fn deduplicate_identities(persons: &[WorkByEmail]) -> Vec<WorkByPerson<'_>> {222fn deduplicate_identities(persons: &[WorkByEmail]) -> Vec<WorkByPerson<'_>> {
214 let mut out = Vec::<WorkByPerson>::new();223 let mut out = Vec::<WorkByPerson>::with_capacity(persons.len());
215 for person_by_email in persons {224 for person_by_email in persons {
216 match out225 match out
217 .iter_mut()226 .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