History

[hours-demo] try sequential version - it's 2.5times slower

So rayon doesn't give perfect scaling here, but it's worth it.

Sebastian Thiel committed 5 years ago

Commit d166cf11 parent 32452451 file · +7 −17Browse files

Unified · Split

demos/hours/src/main.rs+7−17
@@ -72,30 +72,20 @@ fn main() -> anyhow::Result<()> { · 71 unmodified lines
7272
7373 eprintln!("Getting all commit data…");
7474 let start = Instant::now();
75+ let commits_wanted = all_commits.len();
7576 #[allow(clippy::redundant_closure)]
7677 let mut all_commits: Vec<CommitInfo> = all_commits
77− .into_par_iter()
78− .map(|commit_data: Vec<u8>| {
78+ .into_iter()
79+ .filter_map(|commit_data: Vec<u8>| {
7980 git_object::immutable::CommitIter::from_bytes(&commit_data)
8081 .signatures()
8182 .next()
8283 .map(|author| git_object::mutable::Signature::from(author))
8384 })
84− .try_fold(
85− || Vec::new(),
86− |mut out: Vec<_>, item| {
87− out.push(item?);
88− Some(out)
89− },
90− )
91− .try_reduce(
92− || Vec::new(),
93− |mut out, vec| {
94− out.extend(vec.into_iter());
95− Some(out)
96− },
97− )
98− .ok_or_else(|| anyhow!("An error occurred when decoding commits - one commit could not be parsed"))?;
85+ .collect::<Vec<_>>();
86+ if all_commits.len() != commits_wanted {
87+ bail!("An error occurred when decoding commits - one commit could not be parsed");
88+ }
9989 let elapsed = start.elapsed();
10090 eprintln!(
10191 "Obtained {} commits in {:?} ({:0.0} commits/s)",