Closed Philippe-Cholet closed 10 months ago
@phimuemue
After changing fold
(to use enumerate below), I re-ran the benchmark and roughly got 500 ns (so slower). My guess is that it's because + count
is done much more often and not once. (The +1
operations are only moved to enumerate.)
let count = self.count;
let mut f = self.f;
self.iter.enumerate().fold(init, |mut acc, (idx, val)| {
if f(val) {
acc = func(acc, idx + count);
}
acc
})
A very small loss for rfold
.
@phimuemue After changing
fold
(to use enumerate below), I re-ran the benchmark and roughly got 500 ns (so slower). My guess is that it's because+ count
is done much more often and not once. (The+1
operations are only moved to enumerate.)let count = self.count; let mut f = self.f; self.iter.enumerate().fold(init, |mut acc, (idx, val)| { if f(val) { acc = func(acc, idx + count); } acc })
A very small loss for
rfold
.
I meant replacing iter
/count
in Positions
entirely, not just in [r]fold
. So, I suggest merging this PR, and afterwards replacing Positions
's fields.
Related to #755
First, I have to say that after adding many benchmarks in #806, building specialization benchmarks is now slower: 1mn53s hence more than 4mn to run this benchmarking command twice:
Benchmarks all rely on
core::slice::Iter
which does not specializerfold
but I did not thought it would be slower. It's not by much but still. What do you think?