diff --git a/NOTICE.txt b/NOTICE.txt
index 4a81a50be05..8c846a8667a 100644
--- a/NOTICE.txt
+++ b/NOTICE.txt
@@ -216,13 +216,3 @@ In addition, certain files include the notices provided below.
// shall not be used in advertising or otherwise to promote the sale,
// use or other dealings in these Data Files or Software without prior
// written authorization of the copyright holder.
-
-----------------------
-
-/* Written in 2018 by David Blackman and Sebastiano Vigna (vigna@acm.org)
-
-To the extent possible under law, the author has dedicated all copyright
-and related and neighboring rights to this software to the public domain
-worldwide. This software is distributed without any warranty.
-
-See . */
diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt
index b551efa42cc..92f10d10ab0 100644
--- a/benchmarks/CMakeLists.txt
+++ b/benchmarks/CMakeLists.txt
@@ -46,23 +46,15 @@ set_property(CACHE STL_BENCHMARK_MSVC_RUNTIME_LIBRARY
)
set(CMAKE_MSVC_RUNTIME_LIBRARY "${STL_BENCHMARK_MSVC_RUNTIME_LIBRARY}")
-set(STL_BENCHMARK_ITERATOR_DEBUG_LEVEL
- default
- CACHE STRING "What level of iterator debugging to use."
-)
-set_property(CACHE STL_BENCHMARK_ITERATOR_DEBUG_LEVEL
- PROPERTY STRINGS
- "default;0;1;2"
-)
-
-if(NOT STL_BENCHMARK_ITERATOR_DEBUG_LEVEL STREQUAL "default")
- add_compile_definitions("_ITERATOR_DEBUG_LEVEL=${STL_BENCHMARK_ITERATOR_DEBUG_LEVEL}")
-endif()
-
-set(CMAKE_BUILD_TYPE RelWithDebInfo)
+# Building the benchmarks as Release optimizes them with `/O2 /Ob2`.
+# Compiling with `/Zi` and linking with `/DEBUG` below makes profiling possible.
+# (RelWithDebInfo would use `/O2 /Ob1 /Zi`.) See GH-4496.
+set(CMAKE_BUILD_TYPE Release)
# /utf-8 affects .
-add_compile_options("$<$:/diagnostics:caret;/W4;/WX;/w14265;/w15038;/w15262;/utf-8;/Zc:preprocessor>")
+add_compile_options("$<$:/Zi;/nologo;/diagnostics:caret;/W4;/WX;/w14265;/w15038;/w15262;/utf-8;/Zc:preprocessor>")
+
+add_link_options("/DEBUG")
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/google-benchmark/.git")
message(FATAL_ERROR "google-benchmark is not checked out; make sure to run\n git submodule update --init benchmarks/google-benchmark")
@@ -72,15 +64,13 @@ set(BENCHMARK_ENABLE_DOXYGEN OFF)
set(BENCHMARK_ENABLE_INSTALL OFF)
set(BENCHMARK_ENABLE_TESTING OFF)
-set(HAVE_GNU_POSIX_REGEX OFF)
-set(HAVE_POSIX_REGEX OFF)
-
add_subdirectory(google-benchmark EXCLUDE_FROM_ALL)
set(benchmark_headers
+ "inc/lorem.hpp"
+ "inc/skewed_allocator.hpp"
"inc/udt.hpp"
"inc/utility.hpp"
- "inc/xoshiro.hpp"
)
function(add_benchmark name)
@@ -130,7 +120,6 @@ add_benchmark(std_copy src/std_copy.cpp)
add_benchmark(sv_equal src/sv_equal.cpp)
add_benchmark(swap_ranges src/swap_ranges.cpp)
add_benchmark(unique src/unique.cpp)
-
-add_benchmark(vector_bool_copy src/std/containers/sequences/vector.bool/copy/test.cpp)
-add_benchmark(vector_bool_copy_n src/std/containers/sequences/vector.bool/copy_n/test.cpp)
-add_benchmark(vector_bool_move src/std/containers/sequences/vector.bool/move/test.cpp)
+add_benchmark(vector_bool_copy src/vector_bool_copy.cpp)
+add_benchmark(vector_bool_copy_n src/vector_bool_copy_n.cpp)
+add_benchmark(vector_bool_move src/vector_bool_move.cpp)
diff --git a/benchmarks/google-benchmark b/benchmarks/google-benchmark
index c58e6d07105..afa23b7699c 160000
--- a/benchmarks/google-benchmark
+++ b/benchmarks/google-benchmark
@@ -1 +1 @@
-Subproject commit c58e6d0710581e3a08d65c349664128a8d9a2461
+Subproject commit afa23b7699c17f1e26c88cbf95257b20d78d6247
diff --git a/benchmarks/inc/utility.hpp b/benchmarks/inc/utility.hpp
index ecfe0890a16..eacb3fc6d36 100644
--- a/benchmarks/inc/utility.hpp
+++ b/benchmarks/inc/utility.hpp
@@ -5,17 +5,12 @@
#include
#include
-#include
#include
#include
-#include
-
template
std::vector random_vector(size_t n) {
- std::random_device rd;
- std::uniform_int_distribution id64;
- xoshiro256ss prng{id64(rd), id64(rd), id64(rd), id64(rd)};
+ std::mt19937_64 prng;
std::vector res(n);
@@ -25,7 +20,7 @@ std::vector random_vector(size_t n) {
// but is insufficient for aggregate or non_trivial.
#pragma warning(push)
#pragma warning(disable : 4244) // warning C4244: conversion from 'uint64_t' to 'Data', possible loss of data
- std::generate(res.begin(), res.end(), [&prng] { return static_cast(prng.next()); });
+ std::generate(res.begin(), res.end(), [&prng] { return static_cast(prng()); });
#pragma warning(pop)
return res;
diff --git a/benchmarks/inc/xoshiro.hpp b/benchmarks/inc/xoshiro.hpp
deleted file mode 100644
index 3a302105da0..00000000000
--- a/benchmarks/inc/xoshiro.hpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Written in 2018 by David Blackman and Sebastiano Vigna (vigna@acm.org)
-
-To the extent possible under law, the author has dedicated all copyright
-and related and neighboring rights to this software to the public domain
-worldwide. This software is distributed without any warranty.
-
-See .
-SPDX-License-Identifier: CC0-1.0 */
-
-#pragma once
-
-#include
-#include
-
-struct xoshiro256ss {
- xoshiro256ss() = delete;
- xoshiro256ss(std::uint64_t s0, std::uint64_t s1, std::uint64_t s2, std::uint64_t s3)
- : s0_(s0), s1_(s1), s2_(s2), s3_(s3) {}
-
- std::uint64_t next() {
- auto result = std::rotl(s1_ * 5, 7) * 9;
-
- const std::uint64_t t = s1_ << 17;
-
- s2_ ^= s0_;
- s3_ ^= s1_;
- s1_ ^= s2_;
- s0_ ^= s3_;
-
- s2_ ^= t;
-
- s3_ = std::rotl(s3_, 45);
-
- return result;
- }
-
-private:
- std::uint64_t s0_;
- std::uint64_t s1_;
- std::uint64_t s2_;
- std::uint64_t s3_;
-};
diff --git a/benchmarks/src/bitset_from_string.cpp b/benchmarks/src/bitset_from_string.cpp
index 6626e9bad7e..cf0c48b52d3 100644
--- a/benchmarks/src/bitset_from_string.cpp
+++ b/benchmarks/src/bitset_from_string.cpp
@@ -12,89 +12,86 @@
using namespace std;
-namespace {
- template
- auto random_digits_init() {
- mt19937_64 rnd{};
- uniform_int_distribution<> dis('0', '1');
+template
+auto random_digits_init() {
+ mt19937_64 rnd{};
+ uniform_int_distribution<> dis('0', '1');
- constexpr size_t number_of_bitsets = (Min_length + N - 1) / N;
- static_assert(number_of_bitsets != 0);
+ constexpr size_t number_of_bitsets = (Min_length + N - 1) / N;
+ static_assert(number_of_bitsets != 0);
- constexpr size_t actual_size = number_of_bitsets * (N + 1); // +1 for \0
+ constexpr size_t actual_size = number_of_bitsets * (N + 1); // +1 for \0
- array result;
+ array result;
- for (size_t i = 0; i < actual_size; ++i) {
- if (i % (N + 1) == N) {
- result[i] = charT{'\0'}; // write null terminators
- } else {
- result[i] = static_cast(dis(rnd)); // fill random digits
- }
+ for (size_t i = 0; i < actual_size; ++i) {
+ if (i % (N + 1) == N) {
+ result[i] = charT{'\0'}; // write null terminators
+ } else {
+ result[i] = static_cast(dis(rnd)); // fill random digits
}
-
- return result;
}
- enum class length_type : bool { char_count, null_term };
-
- template
- const auto random_digits = random_digits_init();
-
- template
- void bitset_from_string(benchmark::State& state) {
- const auto& digit_array = random_digits;
- for (auto _ : state) {
- benchmark::DoNotOptimize(digit_array);
- const auto arr_data = digit_array.data();
- const auto arr_size = digit_array.size();
- for (size_t pos = 0; pos != arr_size; pos += N + 1) {
- if constexpr (Length == length_type::char_count) {
- bitset bs(arr_data + pos, N);
- benchmark::DoNotOptimize(bs);
- } else {
- bitset bs(arr_data + pos);
- benchmark::DoNotOptimize(bs);
- }
+ return result;
+}
+
+enum class length_type : bool { char_count, null_term };
+
+template
+const auto random_digits = random_digits_init();
+
+template
+void bitset_from_string(benchmark::State& state) {
+ const auto& digit_array = random_digits;
+ for (auto _ : state) {
+ benchmark::DoNotOptimize(digit_array);
+ const auto arr_data = digit_array.data();
+ const auto arr_size = digit_array.size();
+ for (size_t pos = 0; pos != arr_size; pos += N + 1) {
+ if constexpr (Length == length_type::char_count) {
+ bitset bs(arr_data + pos, N);
+ benchmark::DoNotOptimize(bs);
+ } else {
+ bitset bs(arr_data + pos);
+ benchmark::DoNotOptimize(bs);
}
}
}
-
- template
- basic_string random_digits_contiguous_string_init() {
- mt19937_64 rnd{};
- uniform_int_distribution<> dis('0', '1');
-
- basic_string result;
-
- result.resize_and_overwrite(Length, [&](charT* ptr, size_t) {
- generate_n(ptr, Length, [&] { return static_cast(dis(rnd)); });
- return Length;
- });
-
- return result;
- }
-
- template
- const auto random_digits_contiguous_string = random_digits_contiguous_string_init();
-
- template
- void bitset_from_stream(benchmark::State& state) {
- constexpr size_t string_length = 2048;
- constexpr size_t count = string_length / N;
- basic_istringstream stream(random_digits_contiguous_string);
- bitset bs;
- for (auto _ : state) {
- benchmark::DoNotOptimize(stream);
- for (size_t i = 0; i != count; ++i) {
- stream >> bs;
- }
- benchmark::DoNotOptimize(bs);
- stream.seekg(0);
+}
+
+template
+basic_string random_digits_contiguous_string_init() {
+ mt19937_64 rnd{};
+ uniform_int_distribution<> dis('0', '1');
+
+ basic_string result;
+
+ result.resize_and_overwrite(Length, [&](charT* ptr, size_t) {
+ generate_n(ptr, Length, [&] { return static_cast(dis(rnd)); });
+ return Length;
+ });
+
+ return result;
+}
+
+template
+const auto random_digits_contiguous_string = random_digits_contiguous_string_init();
+
+template
+void bitset_from_stream(benchmark::State& state) {
+ constexpr size_t string_length = 2048;
+ constexpr size_t count = string_length / N;
+ basic_istringstream stream(random_digits_contiguous_string);
+ bitset bs;
+ for (auto _ : state) {
+ benchmark::DoNotOptimize(stream);
+ for (size_t i = 0; i != count; ++i) {
+ stream >> bs;
}
+ benchmark::DoNotOptimize(bs);
+ stream.seekg(0);
}
-
-} // namespace
+}
BENCHMARK(bitset_from_string);
BENCHMARK(bitset_from_string);
diff --git a/benchmarks/src/bitset_to_string.cpp b/benchmarks/src/bitset_to_string.cpp
index 5fc88147839..0dcc1031a7a 100644
--- a/benchmarks/src/bitset_to_string.cpp
+++ b/benchmarks/src/bitset_to_string.cpp
@@ -12,45 +12,43 @@
using namespace std;
-namespace {
- template
- auto random_bits_init() {
- mt19937_64 rnd{};
- array arr;
- for (auto& d : arr) {
- d = rnd();
- }
- return arr;
+template
+auto random_bits_init() {
+ mt19937_64 rnd{};
+ array arr;
+ for (auto& d : arr) {
+ d = rnd();
}
+ return arr;
+}
- template
- const auto random_bits = random_bits_init();
+template
+const auto random_bits = random_bits_init();
- template
- void BM_bitset_to_string(benchmark::State& state) {
- static_assert(N <= 64);
+template
+void BM_bitset_to_string(benchmark::State& state) {
+ static_assert(N <= 64);
- for (auto _ : state) {
- for (const auto& bits : random_bits<>) {
- benchmark::DoNotOptimize(bits);
- bitset bs{bits};
- benchmark::DoNotOptimize(bs.to_string());
- }
+ for (auto _ : state) {
+ for (const auto& bits : random_bits<>) {
+ benchmark::DoNotOptimize(bits);
+ bitset bs{bits};
+ benchmark::DoNotOptimize(bs.to_string());
}
}
+}
- template
- void BM_bitset_to_string_large_single(benchmark::State& state) {
- static_assert(N % 64 == 0 && N >= 64);
- const auto& bitset_data = random_bits;
+template
+void BM_bitset_to_string_large_single(benchmark::State& state) {
+ static_assert(N % 64 == 0 && N >= 64);
+ const auto& bitset_data = random_bits;
- const auto large_bitset = bit_cast>(bitset_data);
- for (auto _ : state) {
- benchmark::DoNotOptimize(large_bitset);
- benchmark::DoNotOptimize(large_bitset.to_string());
- }
+ const auto large_bitset = bit_cast>(bitset_data);
+ for (auto _ : state) {
+ benchmark::DoNotOptimize(large_bitset);
+ benchmark::DoNotOptimize(large_bitset.to_string());
}
-} // namespace
+}
BENCHMARK(BM_bitset_to_string<15, char>);
BENCHMARK(BM_bitset_to_string<64, char>);
diff --git a/benchmarks/src/efficient_nonlocking_print.cpp b/benchmarks/src/efficient_nonlocking_print.cpp
index d14973ddc9e..1a6381f8436 100644
--- a/benchmarks/src/efficient_nonlocking_print.cpp
+++ b/benchmarks/src/efficient_nonlocking_print.cpp
@@ -12,33 +12,31 @@
#include
#include
-namespace {
- using PrintType = void (*)(FILE*, std::string_view, std::format_args);
+using PrintType = void (*)(FILE*, std::string_view, std::format_args);
- template
- void BM_vprint(benchmark::State& state) {
- for (auto _ : state) {
- PrintFunction(stdout, "Hello cool I am going to print as unicode\n", std::make_format_args());
- }
+template
+void BM_vprint(benchmark::State& state) {
+ for (auto _ : state) {
+ PrintFunction(stdout, "Hello cool I am going to print as unicode\n", std::make_format_args());
}
- BENCHMARK(BM_vprint<&std::vprint_unicode>);
- BENCHMARK(BM_vprint<&std::vprint_unicode_buffered>);
+}
+BENCHMARK(BM_vprint<&std::vprint_unicode>);
+BENCHMARK(BM_vprint<&std::vprint_unicode_buffered>);
- template
- void BM_vprint_complex(benchmark::State& state) {
- const int i = 42;
- const std::string str = "Hello world!!!!!!!!!!!!!!!!!!!!!!!!";
- const double f = -902.16283758;
- const std::pair p{16, 2.073f};
- for (auto _ : state) {
- PrintFunction(stdout,
- "Hello cool I am going to print as unicode!! {:X}, {}, {:a}, "
- "I am a big string, lots of words, multiple {} formats\n",
- std::make_format_args(i, str, f, p));
- }
+template
+void BM_vprint_complex(benchmark::State& state) {
+ const int i = 42;
+ const std::string str = "Hello world!!!!!!!!!!!!!!!!!!!!!!!!";
+ const double f = -902.16283758;
+ const std::pair p{16, 2.073f};
+ for (auto _ : state) {
+ PrintFunction(stdout,
+ "Hello cool I am going to print as unicode!! {:X}, {}, {:a}, "
+ "I am a big string, lots of words, multiple {} formats\n",
+ std::make_format_args(i, str, f, p));
}
- BENCHMARK(BM_vprint_complex<&std::vprint_unicode>);
- BENCHMARK(BM_vprint_complex<&std::vprint_unicode_buffered>);
-} // namespace
+}
+BENCHMARK(BM_vprint_complex<&std::vprint_unicode>);
+BENCHMARK(BM_vprint_complex<&std::vprint_unicode_buffered>);
BENCHMARK_MAIN();
diff --git a/benchmarks/src/locale_classic.cpp b/benchmarks/src/locale_classic.cpp
index 0f2e9527cd7..cac18e5a15f 100644
--- a/benchmarks/src/locale_classic.cpp
+++ b/benchmarks/src/locale_classic.cpp
@@ -6,7 +6,7 @@
using namespace std;
// GH-3048 : Double-checked locking for locale::classic
-static void BM_locale_classic(benchmark::State& state) {
+void BM_locale_classic(benchmark::State& state) {
for (auto _ : state) {
benchmark::DoNotOptimize(locale::classic());
}
diff --git a/benchmarks/src/path_lexically_normal.cpp b/benchmarks/src/path_lexically_normal.cpp
index 9b5498ddfa1..24b308ab6c5 100644
--- a/benchmarks/src/path_lexically_normal.cpp
+++ b/benchmarks/src/path_lexically_normal.cpp
@@ -5,24 +5,22 @@
#include
#include
-namespace {
- void BM_lexically_normal(benchmark::State& state) {
- using namespace std::literals;
- static constexpr std::wstring_view args[5]{
- LR"(C:Snippets)"sv,
- LR"(.\Snippets)"sv,
- LR"(..\..\IDE\VC\Snippets)"sv,
- LR"(C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\VC\Snippets)"sv,
- LR"(/\server/\share/\a/\b/\c/\./\./\d/\../\../\../\../\../\../\../\other/x/y/z/.././..\meow.txt)"sv,
- };
+void BM_lexically_normal(benchmark::State& state) {
+ using namespace std::literals;
+ static constexpr std::wstring_view args[5]{
+ LR"(C:Snippets)"sv,
+ LR"(.\Snippets)"sv,
+ LR"(..\..\IDE\VC\Snippets)"sv,
+ LR"(C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\VC\Snippets)"sv,
+ LR"(/\server/\share/\a/\b/\c/\./\./\d/\../\../\../\../\../\../\../\other/x/y/z/.././..\meow.txt)"sv,
+ };
- const auto index = state.range(0);
- const std::filesystem::path p(args[index]);
- for (auto _ : state) {
- benchmark::DoNotOptimize(p.lexically_normal());
- }
+ const auto index = state.range(0);
+ const std::filesystem::path p(args[index]);
+ for (auto _ : state) {
+ benchmark::DoNotOptimize(p.lexically_normal());
}
-} // namespace
+}
BENCHMARK(BM_lexically_normal)->DenseRange(0, 4, 1);
diff --git a/benchmarks/src/priority_queue_push_range.cpp b/benchmarks/src/priority_queue_push_range.cpp
index 444d2c2b30d..c15663c90e4 100644
--- a/benchmarks/src/priority_queue_push_range.cpp
+++ b/benchmarks/src/priority_queue_push_range.cpp
@@ -14,58 +14,56 @@
#include
using namespace std;
-namespace {
- constexpr size_t vec_size = 10'000;
+constexpr size_t vec_size = 10'000;
- template
- auto create_vec(Fn transformation) {
- vector vec(vec_size);
- for (mt19937_64 rnd(1); auto& e : vec) {
- e = transformation(rnd());
- }
- return vec;
+template
+auto create_vec(Fn transformation) {
+ vector vec(vec_size);
+ for (mt19937_64 rnd(1); auto& e : vec) {
+ e = transformation(rnd());
}
+ return vec;
+}
- template
- T cast_to(uint64_t val) {
- return static_cast(val);
- }
+template
+T cast_to(uint64_t val) {
+ return static_cast(val);
+}
- const auto vec_u8 = create_vec(cast_to);
- const auto vec_u16 = create_vec(cast_to);
- const auto vec_u32 = create_vec(cast_to);
- const auto vec_u64 = create_vec(cast_to);
- const auto vec_float = create_vec(cast_to);
- const auto vec_double = create_vec(cast_to);
+const auto vec_u8 = create_vec(cast_to);
+const auto vec_u16 = create_vec(cast_to);
+const auto vec_u32 = create_vec(cast_to);
+const auto vec_u64 = create_vec(cast_to);
+const auto vec_float = create_vec(cast_to);
+const auto vec_double = create_vec(cast_to);
- const auto vec_str = create_vec([](uint64_t val) { return to_string(static_cast(val)); });
- const auto vec_wstr = create_vec([](uint64_t val) { return to_wstring(static_cast(val)); });
+const auto vec_str = create_vec([](uint64_t val) { return to_string(static_cast(val)); });
+const auto vec_wstr = create_vec([](uint64_t val) { return to_wstring(static_cast(val)); });
- template
- void BM_push_range(benchmark::State& state) {
- const size_t frag_size = static_cast(state.range(0));
+template
+void BM_push_range(benchmark::State& state) {
+ const size_t frag_size = static_cast(state.range(0));
- for (auto _ : state) {
- priority_queue que;
- span spn{Data};
+ for (auto _ : state) {
+ priority_queue que;
+ span spn{Data};
- while (!spn.empty()) {
- const size_t take_size = min(spn.size(), frag_size);
- que.push_range(spn.first(take_size));
- spn = spn.subspan(take_size);
- }
- benchmark::DoNotOptimize(que);
+ while (!spn.empty()) {
+ const size_t take_size = min(spn.size(), frag_size);
+ que.push_range(spn.first(take_size));
+ spn = spn.subspan(take_size);
}
+ benchmark::DoNotOptimize(que);
}
+}
- template
- void putln(const benchmark::State&) {
- static bool b = [] {
- puts("");
- return true;
- }();
- }
-} // namespace
+template
+void putln(const benchmark::State&) {
+ static bool b = [] {
+ puts("");
+ return true;
+ }();
+}
#define TEST_PUSH_RANGE(T, source) \
BENCHMARK(BM_push_range) \
diff --git a/benchmarks/src/random_integer_generation.cpp b/benchmarks/src/random_integer_generation.cpp
index ebe5d668738..9c1615a5bc1 100644
--- a/benchmarks/src/random_integer_generation.cpp
+++ b/benchmarks/src/random_integer_generation.cpp
@@ -7,7 +7,7 @@
/// Test URBGs alone
-static void BM_mt19937(benchmark::State& state) {
+void BM_mt19937(benchmark::State& state) {
std::mt19937 gen;
for (auto _ : state) {
benchmark::DoNotOptimize(gen());
@@ -15,7 +15,7 @@ static void BM_mt19937(benchmark::State& state) {
}
BENCHMARK(BM_mt19937);
-static void BM_mt19937_64(benchmark::State& state) {
+void BM_mt19937_64(benchmark::State& state) {
std::mt19937_64 gen;
for (auto _ : state) {
benchmark::DoNotOptimize(gen());
@@ -23,7 +23,7 @@ static void BM_mt19937_64(benchmark::State& state) {
}
BENCHMARK(BM_mt19937_64);
-static void BM_lcg(benchmark::State& state) {
+void BM_lcg(benchmark::State& state) {
std::minstd_rand gen;
for (auto _ : state) {
benchmark::DoNotOptimize(gen());
@@ -32,16 +32,16 @@ static void BM_lcg(benchmark::State& state) {
BENCHMARK(BM_lcg);
std::uint32_t GetMax() {
- std::random_device gen;
+ std::mt19937 gen;
std::uniform_int_distribution dist(10'000'000, 20'000'000);
return dist(gen);
}
-static const std::uint32_t maximum = GetMax(); // random divisor to prevent strength reduction
+const std::uint32_t maximum = GetMax(); // random divisor to prevent strength reduction
/// Test mt19937
-static void BM_raw_mt19937_old(benchmark::State& state) {
+void BM_raw_mt19937_old(benchmark::State& state) {
std::mt19937 gen;
std::_Rng_from_urng rng(gen);
for (auto _ : state) {
@@ -50,7 +50,7 @@ static void BM_raw_mt19937_old(benchmark::State& state) {
}
BENCHMARK(BM_raw_mt19937_old);
-static void BM_raw_mt19937_new(benchmark::State& state) {
+void BM_raw_mt19937_new(benchmark::State& state) {
std::mt19937 gen;
std::_Rng_from_urng_v2 rng(gen);
for (auto _ : state) {
@@ -61,7 +61,7 @@ BENCHMARK(BM_raw_mt19937_new);
/// Test mt19937_64
-static void BM_raw_mt19937_64_old(benchmark::State& state) {
+void BM_raw_mt19937_64_old(benchmark::State& state) {
std::mt19937_64 gen;
std::_Rng_from_urng rng(gen);
for (auto _ : state) {
@@ -70,7 +70,7 @@ static void BM_raw_mt19937_64_old(benchmark::State& state) {
}
BENCHMARK(BM_raw_mt19937_64_old);
-static void BM_raw_mt19937_64_new(benchmark::State& state) {
+void BM_raw_mt19937_64_new(benchmark::State& state) {
std::mt19937_64 gen;
std::_Rng_from_urng_v2 rng(gen);
for (auto _ : state) {
@@ -81,7 +81,7 @@ BENCHMARK(BM_raw_mt19937_64_new);
/// Test minstd_rand
-static void BM_raw_lcg_old(benchmark::State& state) {
+void BM_raw_lcg_old(benchmark::State& state) {
std::minstd_rand gen;
std::_Rng_from_urng rng(gen);
for (auto _ : state) {
@@ -90,7 +90,7 @@ static void BM_raw_lcg_old(benchmark::State& state) {
}
BENCHMARK(BM_raw_lcg_old);
-static void BM_raw_lcg_new(benchmark::State& state) {
+void BM_raw_lcg_new(benchmark::State& state) {
std::minstd_rand gen;
std::_Rng_from_urng_v2 rng(gen);
for (auto _ : state) {
diff --git a/benchmarks/src/std_copy.cpp b/benchmarks/src/std_copy.cpp
index 5aa07e56b40..40c2cb7c148 100644
--- a/benchmarks/src/std_copy.cpp
+++ b/benchmarks/src/std_copy.cpp
@@ -11,80 +11,77 @@
#include
#include
-namespace {
- template
- void handwritten_loop(benchmark::State& state) {
- const size_t r0 = static_cast(state.range(0));
- const auto in_buffer = random_vector(r0);
- std::vector out_buffer(r0);
- for ([[maybe_unused]] auto _ : state) {
- benchmark::DoNotOptimize(in_buffer.data());
- const Contained* in_ptr = in_buffer.data();
- const Contained* const in_ptr_end = in_ptr + r0;
- Contained* out_ptr = out_buffer.data();
- while (in_ptr != in_ptr_end) {
- *out_ptr++ = *in_ptr++;
- }
-
- benchmark::DoNotOptimize(out_buffer.data());
+template
+void handwritten_loop(benchmark::State& state) {
+ const size_t r0 = static_cast(state.range(0));
+ const auto in_buffer = random_vector(r0);
+ std::vector out_buffer(r0);
+ for ([[maybe_unused]] auto _ : state) {
+ benchmark::DoNotOptimize(in_buffer.data());
+ const Contained* in_ptr = in_buffer.data();
+ const Contained* const in_ptr_end = in_ptr + r0;
+ Contained* out_ptr = out_buffer.data();
+ while (in_ptr != in_ptr_end) {
+ *out_ptr++ = *in_ptr++;
}
- }
- template
- void handwritten_loop_n(benchmark::State& state) {
- const size_t r0 = static_cast(state.range(0));
- const auto in_buffer = random_vector(r0);
- std::vector out_buffer(r0);
- for ([[maybe_unused]] auto _ : state) {
- benchmark::DoNotOptimize(in_buffer.data());
- const Contained* const in_ptr = in_buffer.data();
- Contained* const out_ptr = out_buffer.data();
- for (size_t idx = 0; idx < r0; ++idx) {
- out_ptr[idx] = in_ptr[idx];
- }
-
- benchmark::DoNotOptimize(out_buffer.data());
- }
+ benchmark::DoNotOptimize(out_buffer.data());
}
-
- template
- void memcpy_call(benchmark::State& state) {
- static_assert(
- std::is_trivially_copyable_v, "memcpy must only be called on trivially copyable types");
- const size_t r0 = static_cast(state.range(0));
- const auto in_buffer = random_vector(r0);
- std::vector out_buffer(r0);
- for ([[maybe_unused]] auto _ : state) {
- benchmark::DoNotOptimize(in_buffer.data());
- memcpy(out_buffer.data(), in_buffer.data(), r0 * sizeof(Contained));
- benchmark::DoNotOptimize(out_buffer.data());
+}
+
+template
+void handwritten_loop_n(benchmark::State& state) {
+ const size_t r0 = static_cast(state.range(0));
+ const auto in_buffer = random_vector(r0);
+ std::vector out_buffer(r0);
+ for ([[maybe_unused]] auto _ : state) {
+ benchmark::DoNotOptimize(in_buffer.data());
+ const Contained* const in_ptr = in_buffer.data();
+ Contained* const out_ptr = out_buffer.data();
+ for (size_t idx = 0; idx < r0; ++idx) {
+ out_ptr[idx] = in_ptr[idx];
}
- }
- template
- void std_copy_call(benchmark::State& state) {
- const size_t r0 = static_cast(state.range(0));
- const auto in_buffer = random_vector(r0);
- std::vector out_buffer(r0);
- for ([[maybe_unused]] auto _ : state) {
- benchmark::DoNotOptimize(in_buffer.data());
- std::copy(in_buffer.begin(), in_buffer.end(), out_buffer.begin());
- benchmark::DoNotOptimize(out_buffer.data());
- }
+ benchmark::DoNotOptimize(out_buffer.data());
}
-
- template
- void std_copy_n_call(benchmark::State& state) {
- const size_t r0 = static_cast(state.range(0));
- const auto in_buffer = random_vector(r0);
- std::vector out_buffer(r0);
- for ([[maybe_unused]] auto _ : state) {
- benchmark::DoNotOptimize(in_buffer.data());
- std::copy_n(in_buffer.begin(), r0, out_buffer.begin());
- benchmark::DoNotOptimize(out_buffer.data());
- }
+}
+
+template
+void memcpy_call(benchmark::State& state) {
+ static_assert(std::is_trivially_copyable_v, "memcpy must only be called on trivially copyable types");
+ const size_t r0 = static_cast(state.range(0));
+ const auto in_buffer = random_vector(r0);
+ std::vector out_buffer(r0);
+ for ([[maybe_unused]] auto _ : state) {
+ benchmark::DoNotOptimize(in_buffer.data());
+ memcpy(out_buffer.data(), in_buffer.data(), r0 * sizeof(Contained));
+ benchmark::DoNotOptimize(out_buffer.data());
+ }
+}
+
+template
+void std_copy_call(benchmark::State& state) {
+ const size_t r0 = static_cast(state.range(0));
+ const auto in_buffer = random_vector(r0);
+ std::vector out_buffer(r0);
+ for ([[maybe_unused]] auto _ : state) {
+ benchmark::DoNotOptimize(in_buffer.data());
+ std::copy(in_buffer.begin(), in_buffer.end(), out_buffer.begin());
+ benchmark::DoNotOptimize(out_buffer.data());
+ }
+}
+
+template
+void std_copy_n_call(benchmark::State& state) {
+ const size_t r0 = static_cast(state.range(0));
+ const auto in_buffer = random_vector(r0);
+ std::vector out_buffer(r0);
+ for ([[maybe_unused]] auto _ : state) {
+ benchmark::DoNotOptimize(in_buffer.data());
+ std::copy_n(in_buffer.begin(), r0, out_buffer.begin());
+ benchmark::DoNotOptimize(out_buffer.data());
}
-} // namespace
+}
BENCHMARK(handwritten_loop)->Range(0, 1 << 18);
BENCHMARK(handwritten_loop_n)->Range(0, 1 << 18);
diff --git a/benchmarks/src/std/containers/sequences/vector.bool/copy/test.cpp b/benchmarks/src/vector_bool_copy.cpp
similarity index 80%
rename from benchmarks/src/std/containers/sequences/vector.bool/copy/test.cpp
rename to benchmarks/src/vector_bool_copy.cpp
index 18e18244514..6cfc2b4f95f 100644
--- a/benchmarks/src/std/containers/sequences/vector.bool/copy/test.cpp
+++ b/benchmarks/src/vector_bool_copy.cpp
@@ -10,14 +10,14 @@
using namespace std;
-static vector createRandomVector(const size_t size) {
- static mt19937 gen{random_device{}()};
+vector createRandomVector(const size_t size) {
+ static mt19937 gen;
vector result(size);
generate_n(result.begin(), size, [] { return bernoulli_distribution{0.5}(gen); });
return result;
}
-static void copy_block_aligned(benchmark::State& state) {
+void copy_block_aligned(benchmark::State& state) {
const auto size = static_cast(state.range(0));
const vector source = createRandomVector(size);
vector dest(size, false);
@@ -27,7 +27,7 @@ static void copy_block_aligned(benchmark::State& state) {
}
}
-static void copy_source_misaligned(benchmark::State& state) {
+void copy_source_misaligned(benchmark::State& state) {
const auto size = static_cast(state.range(0));
const vector source = createRandomVector(size);
vector dest(size, false);
@@ -37,7 +37,7 @@ static void copy_source_misaligned(benchmark::State& state) {
}
}
-static void copy_dest_misaligned(benchmark::State& state) {
+void copy_dest_misaligned(benchmark::State& state) {
const auto size = static_cast(state.range(0));
const vector source = createRandomVector(size);
vector dest(size, false);
@@ -48,7 +48,7 @@ static void copy_dest_misaligned(benchmark::State& state) {
}
// Special benchmark for matching char alignment
-static void copy_matching_alignment(benchmark::State& state) {
+void copy_matching_alignment(benchmark::State& state) {
const auto size = static_cast(state.range(0));
const vector source = createRandomVector(size);
vector dest(size, false);
@@ -59,7 +59,7 @@ static void copy_matching_alignment(benchmark::State& state) {
}
// Special benchmarks for single block corner case
-static void copy_both_single_blocks(benchmark::State& state) {
+void copy_both_single_blocks(benchmark::State& state) {
const vector source = createRandomVector(50);
vector dest(50, false);
@@ -69,7 +69,7 @@ static void copy_both_single_blocks(benchmark::State& state) {
}
}
-static void copy_source_single_block(benchmark::State& state) {
+void copy_source_single_block(benchmark::State& state) {
const vector source = createRandomVector(50);
vector dest(50, false);
@@ -79,7 +79,7 @@ static void copy_source_single_block(benchmark::State& state) {
}
}
-static void copy_dest_single_block(benchmark::State& state) {
+void copy_dest_single_block(benchmark::State& state) {
const vector source = createRandomVector(50);
vector dest(50, false);
diff --git a/benchmarks/src/std/containers/sequences/vector.bool/copy_n/test.cpp b/benchmarks/src/vector_bool_copy_n.cpp
similarity index 80%
rename from benchmarks/src/std/containers/sequences/vector.bool/copy_n/test.cpp
rename to benchmarks/src/vector_bool_copy_n.cpp
index fe52c7036cf..9952c261091 100644
--- a/benchmarks/src/std/containers/sequences/vector.bool/copy_n/test.cpp
+++ b/benchmarks/src/vector_bool_copy_n.cpp
@@ -10,14 +10,14 @@
using namespace std;
-static vector createRandomVector(const size_t size) {
- static mt19937 gen{random_device{}()};
+vector createRandomVector(const size_t size) {
+ static mt19937 gen;
vector result(size);
generate_n(result.begin(), size, [] { return bernoulli_distribution{0.5}(gen); });
return result;
}
-static void copy_n_block_aligned(benchmark::State& state) {
+void copy_n_block_aligned(benchmark::State& state) {
const auto size = static_cast(state.range(0));
const vector source = createRandomVector(size);
vector dest(size, false);
@@ -27,7 +27,7 @@ static void copy_n_block_aligned(benchmark::State& state) {
}
}
-static void copy_n_source_misaligned(benchmark::State& state) {
+void copy_n_source_misaligned(benchmark::State& state) {
const auto size = static_cast(state.range(0));
const vector source = createRandomVector(size);
vector dest(size, false);
@@ -37,7 +37,7 @@ static void copy_n_source_misaligned(benchmark::State& state) {
}
}
-static void copy_n_dest_misaligned(benchmark::State& state) {
+void copy_n_dest_misaligned(benchmark::State& state) {
const auto size = static_cast(state.range(0));
const vector source = createRandomVector(size);
vector dest(size, false);
@@ -48,7 +48,7 @@ static void copy_n_dest_misaligned(benchmark::State& state) {
}
// Special benchmark for matching char alignment
-static void copy_n_matching_alignment(benchmark::State& state) {
+void copy_n_matching_alignment(benchmark::State& state) {
const auto size = static_cast(state.range(0));
const vector source = createRandomVector(size);
vector dest(size, false);
@@ -59,7 +59,7 @@ static void copy_n_matching_alignment(benchmark::State& state) {
}
// Special benchmarks for single block corner case
-static void copy_n_both_single_blocks(benchmark::State& state) {
+void copy_n_both_single_blocks(benchmark::State& state) {
const vector source = createRandomVector(50);
vector dest(50, false);
@@ -69,7 +69,7 @@ static void copy_n_both_single_blocks(benchmark::State& state) {
}
}
-static void copy_n_source_single_block(benchmark::State& state) {
+void copy_n_source_single_block(benchmark::State& state) {
const vector source = createRandomVector(50);
vector dest(50, false);
@@ -79,7 +79,7 @@ static void copy_n_source_single_block(benchmark::State& state) {
}
}
-static void copy_n_dest_single_block(benchmark::State& state) {
+void copy_n_dest_single_block(benchmark::State& state) {
const vector source = createRandomVector(50);
vector dest(50, false);
diff --git a/benchmarks/src/std/containers/sequences/vector.bool/move/test.cpp b/benchmarks/src/vector_bool_move.cpp
similarity index 80%
rename from benchmarks/src/std/containers/sequences/vector.bool/move/test.cpp
rename to benchmarks/src/vector_bool_move.cpp
index 7eefc268ec2..56485c53b8c 100644
--- a/benchmarks/src/std/containers/sequences/vector.bool/move/test.cpp
+++ b/benchmarks/src/vector_bool_move.cpp
@@ -10,14 +10,14 @@
using namespace std;
-static vector createRandomVector(const size_t size) {
- static mt19937 gen{random_device{}()};
+vector createRandomVector(const size_t size) {
+ static mt19937 gen;
vector result(size);
generate_n(result.begin(), size, [] { return bernoulli_distribution{0.5}(gen); });
return result;
}
-static void move_block_aligned(benchmark::State& state) {
+void move_block_aligned(benchmark::State& state) {
const auto size = static_cast(state.range(0));
const vector source = createRandomVector(size);
vector dest(size, false);
@@ -27,7 +27,7 @@ static void move_block_aligned(benchmark::State& state) {
}
}
-static void move_source_misaligned(benchmark::State& state) {
+void move_source_misaligned(benchmark::State& state) {
const auto size = static_cast(state.range(0));
const vector source = createRandomVector(size);
vector dest(size, false);
@@ -37,7 +37,7 @@ static void move_source_misaligned(benchmark::State& state) {
}
}
-static void move_dest_misaligned(benchmark::State& state) {
+void move_dest_misaligned(benchmark::State& state) {
const auto size = static_cast(state.range(0));
const vector source = createRandomVector(size);
vector dest(size, false);
@@ -48,7 +48,7 @@ static void move_dest_misaligned(benchmark::State& state) {
}
// Special benchmark for matching char alignment
-static void move_matching_alignment(benchmark::State& state) {
+void move_matching_alignment(benchmark::State& state) {
const auto size = static_cast(state.range(0));
const vector source = createRandomVector(size);
vector dest(size, false);
@@ -59,7 +59,7 @@ static void move_matching_alignment(benchmark::State& state) {
}
// Special benchmarks for single block corner case
-static void move_both_single_blocks(benchmark::State& state) {
+void move_both_single_blocks(benchmark::State& state) {
const vector source = createRandomVector(50);
vector