[libcxx] r274424 - Add unordered_map::insert benchmark test and rename file

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 1 22:30:54 PDT 2016


Author: ericwf
Date: Sat Jul  2 00:30:54 2016
New Revision: 274424

URL: http://llvm.org/viewvc/llvm-project?rev=274424&view=rev
Log:
Add unordered_map::insert benchmark test and rename file

Added:
    libcxx/trunk/benchmarks/unordered_set_operations.bench.cpp
Removed:
    libcxx/trunk/benchmarks/set_find.pass.cpp

Removed: libcxx/trunk/benchmarks/set_find.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/set_find.pass.cpp?rev=274423&view=auto
==============================================================================
--- libcxx/trunk/benchmarks/set_find.pass.cpp (original)
+++ libcxx/trunk/benchmarks/set_find.pass.cpp (removed)
@@ -1,29 +0,0 @@
-#include <unordered_set>
-#include <vector>
-#include <cstdint>
-
-#include "benchmark/benchmark_api.h"
-
-template <class IntT>
-std::vector<IntT> getInputs(size_t N) {
-    std::vector<IntT> inputs;
-    for (size_t i=0; i < N; ++i) {
-        inputs.push_back(i);
-    }
-    return inputs;
-}
-
-template <class Container, class Inputs>
-void BM_SetLookup(benchmark::State& st, Container c, Inputs const& in) {
-    c.insert(in.begin(), in.end());
-    const auto end = in.end();
-    while (st.KeepRunning()) {
-        for (auto it = in.begin(); it != end; ++it) {
-            benchmark::DoNotOptimize(c.find(*it++));
-        }
-    }
-}
-BENCHMARK_CAPTURE(BM_SetLookup, uint32_lookup,
-    std::unordered_set<uint32_t>{}, getInputs<uint32_t>(1024));
-
-BENCHMARK_MAIN()

Added: libcxx/trunk/benchmarks/unordered_set_operations.bench.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/unordered_set_operations.bench.cpp?rev=274424&view=auto
==============================================================================
--- libcxx/trunk/benchmarks/unordered_set_operations.bench.cpp (added)
+++ libcxx/trunk/benchmarks/unordered_set_operations.bench.cpp Sat Jul  2 00:30:54 2016
@@ -0,0 +1,44 @@
+#include <unordered_set>
+#include <vector>
+#include <cstdint>
+
+#include "benchmark/benchmark_api.h"
+
+template <class IntT>
+std::vector<IntT> getInputs(size_t N) {
+    std::vector<IntT> inputs;
+    for (size_t i=0; i < N; ++i) {
+        inputs.push_back(i);
+    }
+    return inputs;
+}
+
+template <class Container, class Inputs>
+void BM_SetInsert(benchmark::State& st, Container c, Inputs const& in) {
+    const auto end = in.end();
+    while (st.KeepRunning()) {
+        c.clear();
+        for (auto it = in.begin(); it != end; ++it) {
+            benchmark::DoNotOptimize(c.insert(*it));
+        }
+        benchmark::DoNotOptimize(c);
+    }
+}
+BENCHMARK_CAPTURE(BM_SetInsert, uint32_insert,
+    std::unordered_set<uint32_t>{}, getInputs<uint32_t>(1024));
+
+template <class Container, class Inputs>
+void BM_SetFind(benchmark::State& st, Container c, Inputs const& in) {
+    c.insert(in.begin(), in.end());
+    const auto end = in.end();
+    while (st.KeepRunning()) {
+        for (auto it = in.begin(); it != end; ++it) {
+            benchmark::DoNotOptimize(c.find(*it));
+        }
+    }
+}
+BENCHMARK_CAPTURE(BM_SetFind, uint32_lookup,
+    std::unordered_set<uint32_t>{}, getInputs<uint32_t>(1024));
+
+
+BENCHMARK_MAIN()




More information about the cfe-commits mailing list