Skip to content

Commit

Permalink
refactor: Preallocate PrevectorFillVector(In)Direct without vector re…
Browse files Browse the repository at this point in the history
…size

The prevector benchmarks were likely not trying to measure vector resize performance.
  • Loading branch information
l0rinc committed Nov 25, 2024
1 parent a774c7a commit 152fefe
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/bench/prevector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ static void PrevectorFillVectorDirect(benchmark::Bench& bench)
{
bench.run([&] {
std::vector<prevector<28, T>> vec;
vec.reserve(260);
for (size_t i = 0; i < 260; ++i) {
vec.emplace_back();
}
Expand All @@ -99,6 +100,7 @@ static void PrevectorFillVectorIndirect(benchmark::Bench& bench)
{
bench.run([&] {
std::vector<prevector<28, T>> vec;
vec.reserve(260);
for (size_t i = 0; i < 260; ++i) {
// force allocation
vec.emplace_back(29, T{});
Expand Down

0 comments on commit 152fefe

Please sign in to comment.