From 152fefe7a22b7da3cfe2815083634bece9c5654e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Mon, 18 Nov 2024 16:18:10 +0100 Subject: [PATCH] refactor: Preallocate PrevectorFillVector(In)Direct without vector resize The prevector benchmarks were likely not trying to measure vector resize performance. --- src/bench/prevector.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bench/prevector.cpp b/src/bench/prevector.cpp index 9b83c42693fd3..adc3d18de000c 100644 --- a/src/bench/prevector.cpp +++ b/src/bench/prevector.cpp @@ -87,6 +87,7 @@ static void PrevectorFillVectorDirect(benchmark::Bench& bench) { bench.run([&] { std::vector> vec; + vec.reserve(260); for (size_t i = 0; i < 260; ++i) { vec.emplace_back(); } @@ -99,6 +100,7 @@ static void PrevectorFillVectorIndirect(benchmark::Bench& bench) { bench.run([&] { std::vector> vec; + vec.reserve(260); for (size_t i = 0; i < 260; ++i) { // force allocation vec.emplace_back(29, T{});