Closed chinoto closed 2 years ago
Yeah, I've had the same issues with unstable benchmarks. Unclear on what causes it, have tried with more test data but does not seem to do much difference. Criterion might help.
The current insert test does not exercise increase_cache
as it already is has the correct capacity. Will a few more test and increase the amount of test data.
I was hoping this might be slightly more efficient because the internal Vecs aren't being moved and the collect knows exactly what capacity to make the new outer Vec, but the benchmark was too wibbly-wobbly to know for sure if this helps. Maybe criterion would be more accurate? At least the code is shorter.
My other idea was to drain all the entries into a single level Vec to preserve the allocations already in self.cache[ix] and minimize further allocations, but that didn't bench very well. My guess is that it is quicker to (de)allocate than copy memory around.