@@ -59,7 +59,7 @@ void associative_container_benchmarks(std::string container) {
5959 auto get_key = [](Value const & v) { return adapt_operations<Container>::key_from_value (v); };
6060
6161 auto bench = [&](std::string operation, auto f) {
62- benchmark::RegisterBenchmark (container + " ::" + operation, f)->Arg (32 )->Arg (1024 )->Arg (8192 );
62+ benchmark::RegisterBenchmark (container + " ::" + operation, f)->Arg (0 )-> Arg ( 32 )->Arg (1024 )->Arg (8192 );
6363 };
6464
6565 static constexpr bool is_multi_key_container =
@@ -176,7 +176,7 @@ void associative_container_benchmarks(std::string container) {
176176 // Insertion
177177 // ///////////////////////
178178 bench (" insert(value) (already present)" , [=](auto & st) {
179- const std::size_t size = st.range (0 );
179+ const std::size_t size = st.range (0 ) ? st. range ( 0 ) : 1 ;
180180 std::vector<Value> in = make_value_types (generate_unique_keys (size));
181181 Value to_insert = in[in.size () / 2 ]; // pick any existing value
182182 std::vector<Container> c (BatchSize, Container (in.begin (), in.end ()));
@@ -371,7 +371,7 @@ void associative_container_benchmarks(std::string container) {
371371 // Erasure
372372 // ///////////////////////
373373 bench (" erase(key) (existent)" , [=](auto & st) {
374- const std::size_t size = st.range (0 );
374+ const std::size_t size = st.range (0 ) ? st. range ( 0 ) : 1 ; // avoid empty container
375375 std::vector<Value> in = make_value_types (generate_unique_keys (size));
376376 Value element = in[in.size () / 2 ]; // pick any element
377377 std::vector<Container> c (BatchSize, Container (in.begin (), in.end ()));
@@ -415,7 +415,7 @@ void associative_container_benchmarks(std::string container) {
415415 });
416416
417417 bench (" erase(iterator)" , [=](auto & st) {
418- const std::size_t size = st.range (0 );
418+ const std::size_t size = st.range (0 ) ? st. range ( 0 ) : 1 ; // avoid empty container
419419 std::vector<Value> in = make_value_types (generate_unique_keys (size));
420420 Value element = in[in.size () / 2 ]; // pick any element
421421
@@ -494,7 +494,7 @@ void associative_container_benchmarks(std::string container) {
494494 Container c (in.begin (), in.end ());
495495
496496 while (st.KeepRunningBatch (BatchSize)) {
497- for (std::size_t i = 0 ; i != BatchSize ; ++i) {
497+ for (std::size_t i = 0 ; i != keys. size () ; ++i) { // possible empty keys when Arg(0)
498498 auto result = func (c, keys[i]);
499499 benchmark::DoNotOptimize (c);
500500 benchmark::DoNotOptimize (result);
0 commit comments