Config is getting big, pass by reference rather than value
[benchmarks.git] / src / common / c11_atomics / c11_atomics_benchmarks.cpp
index 01f831c94812b1455a2eb9ed8b752c2172e87e94..20d02b0ac18708627f678e49d33d86998e59537d 100644 (file)
@@ -47,8 +47,9 @@ MEMORY_ORDER_NAME(seq_cst)
 template <typename T> using Buf = std::shared_ptr<std::vector<std::atomic<T>>>;
 
 template <typename Fn, typename T, typename... NameParts>
-static void push_atomic_bench(std::vector<Benchmark> &benches, Config config,
-                              Buf<T> buf, Fn fn, NameParts &&...name_parts)
+static void push_atomic_bench(std::vector<Benchmark> &benches,
+                              const Config &config, Buf<T> buf, Fn fn,
+                              NameParts &&...name_parts)
 {
     auto log2_stride = config.log2_stride;
     std::size_t index_mask = 1;
@@ -71,8 +72,8 @@ static void push_atomic_bench(std::vector<Benchmark> &benches, Config config,
 }
 
 template <typename T, std::memory_order order>
-static void rmw_benchmarks(std::vector<Benchmark> &benches, Config config,
-                           Buf<T> buf)
+static void rmw_benchmarks(std::vector<Benchmark> &benches,
+                           const Config &config, Buf<T> buf)
 {
     push_atomic_bench(
         benches, config, buf,
@@ -113,8 +114,8 @@ static void rmw_benchmarks(std::vector<Benchmark> &benches, Config config,
 }
 
 template <typename T, std::memory_order order>
-static void load_benchmarks(std::vector<Benchmark> &benches, Config config,
-                            Buf<T> buf)
+static void load_benchmarks(std::vector<Benchmark> &benches,
+                            const Config &config, Buf<T> buf)
 {
     push_atomic_bench(
         benches, config, buf,
@@ -125,8 +126,8 @@ static void load_benchmarks(std::vector<Benchmark> &benches, Config config,
 }
 
 template <typename T, std::memory_order order>
-static void store_benchmarks(std::vector<Benchmark> &benches, Config config,
-                             Buf<T> buf)
+static void store_benchmarks(std::vector<Benchmark> &benches,
+                             const Config &config, Buf<T> buf)
 {
     push_atomic_bench(
         benches, config, buf,
@@ -137,8 +138,8 @@ static void store_benchmarks(std::vector<Benchmark> &benches, Config config,
 }
 
 template <typename T, std::memory_order succ, std::memory_order fail>
-static void cmp_xchg_benchmarks(std::vector<Benchmark> &benches, Config config,
-                                Buf<T> buf)
+static void cmp_xchg_benchmarks(std::vector<Benchmark> &benches,
+                                const Config &config, Buf<T> buf)
 {
     push_atomic_bench(
         benches, config, buf,
@@ -163,7 +164,7 @@ static void cmp_xchg_benchmarks(std::vector<Benchmark> &benches, Config config,
 }
 
 template <typename T>
-static void benchmarks(std::vector<Benchmark> &benches, Config config)
+static void benchmarks(std::vector<Benchmark> &benches, const Config &config)
 {
     std::size_t buf_size = 1;
     buf_size <<= config.log2_memory_location_count;
@@ -208,7 +209,7 @@ static void benchmarks(std::vector<Benchmark> &benches, Config config)
                         std::memory_order_seq_cst>(benches, config, buf);
 }
 
-std::vector<Benchmark> c11_atomics_benchmarks(Config config)
+std::vector<Benchmark> c11_atomics_benchmarks(const Config &config)
 {
     std::vector<Benchmark> benches;
     benchmarks<std::uint8_t>(benches, config);