[libcxx-commits] [libcxx] r369487 - libcxx: Rename .hpp files in libcxx/benchmarks to .h
Nico Weber via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 20 18:59:12 PDT 2019
Author: nico
Date: Tue Aug 20 18:59:12 2019
New Revision: 369487
URL: http://llvm.org/viewvc/llvm-project?rev=369487&view=rev
Log:
libcxx: Rename .hpp files in libcxx/benchmarks to .h
LLVM uses .h as its extension for header files.
Differential Revision: https://reviews.llvm.org/D66509
Added:
libcxx/trunk/benchmarks/CartesianBenchmarks.h
libcxx/trunk/benchmarks/ContainerBenchmarks.h
libcxx/trunk/benchmarks/GenerateInput.h
libcxx/trunk/benchmarks/Utilities.h
Removed:
libcxx/trunk/benchmarks/CartesianBenchmarks.hpp
libcxx/trunk/benchmarks/ContainerBenchmarks.hpp
libcxx/trunk/benchmarks/GenerateInput.hpp
libcxx/trunk/benchmarks/Utilities.hpp
Modified:
libcxx/trunk/benchmarks/algorithms.bench.cpp
libcxx/trunk/benchmarks/algorithms.partition_point.bench.cpp
libcxx/trunk/benchmarks/deque.bench.cpp
libcxx/trunk/benchmarks/filesystem.bench.cpp
libcxx/trunk/benchmarks/function.bench.cpp
libcxx/trunk/benchmarks/ordered_set.bench.cpp
libcxx/trunk/benchmarks/string.bench.cpp
libcxx/trunk/benchmarks/unordered_set_operations.bench.cpp
libcxx/trunk/benchmarks/vector_operations.bench.cpp
Added: libcxx/trunk/benchmarks/CartesianBenchmarks.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/CartesianBenchmarks.h?rev=369487&view=auto
==============================================================================
--- libcxx/trunk/benchmarks/CartesianBenchmarks.h (added)
+++ libcxx/trunk/benchmarks/CartesianBenchmarks.h Tue Aug 20 18:59:12 2019
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+
+#include <string>
+#include <tuple>
+#include <type_traits>
+#include <vector>
+
+#include "benchmark/benchmark.h"
+#include "test_macros.h"
+
+namespace internal {
+
+template <class D, class E, size_t I>
+struct EnumValue : std::integral_constant<E, static_cast<E>(I)> {
+ static std::string name() { return std::string("_") + D::Names[I]; }
+};
+
+template <class D, class E, size_t ...Idxs>
+constexpr auto makeEnumValueTuple(std::index_sequence<Idxs...>) {
+ return std::make_tuple(EnumValue<D, E, Idxs>{}...);
+}
+
+template <class B>
+static auto skip(const B& Bench, int) -> decltype(Bench.skip()) {
+ return Bench.skip();
+}
+template <class B>
+static auto skip(const B& Bench, char) {
+ return false;
+}
+
+template <class B, class Args, size_t... Is>
+void makeBenchmarkFromValuesImpl(const Args& A, std::index_sequence<Is...>) {
+ for (auto& V : A) {
+ B Bench{std::get<Is>(V)...};
+ if (!internal::skip(Bench, 0)) {
+ benchmark::RegisterBenchmark(Bench.name().c_str(),
+ [=](benchmark::State& S) { Bench.run(S); });
+ }
+ }
+}
+
+template <class B, class... Args>
+void makeBenchmarkFromValues(const std::vector<std::tuple<Args...> >& A) {
+ makeBenchmarkFromValuesImpl<B>(A, std::index_sequence_for<Args...>());
+}
+
+template <template <class...> class B, class Args, class... U>
+void makeBenchmarkImpl(const Args& A, std::tuple<U...> t) {
+ makeBenchmarkFromValues<B<U...> >(A);
+}
+
+template <template <class...> class B, class Args, class... U,
+ class... T, class... Tuples>
+void makeBenchmarkImpl(const Args& A, std::tuple<U...>, std::tuple<T...>,
+ Tuples... rest) {
+ (internal::makeBenchmarkImpl<B>(A, std::tuple<U..., T>(), rest...), ...);
+}
+
+template <class R, class T>
+void allValueCombinations(R& Result, const T& Final) {
+ return Result.push_back(Final);
+}
+
+template <class R, class T, class V, class... Vs>
+void allValueCombinations(R& Result, const T& Prev, const V& Value,
+ const Vs&... Values) {
+ for (const auto& E : Value) {
+ allValueCombinations(Result, std::tuple_cat(Prev, std::make_tuple(E)),
+ Values...);
+ }
+}
+
+} // namespace internal
+
+// CRTP class that enables using enum types as a dimension for
+// makeCartesianProductBenchmark below.
+// The type passed to `B` will be a std::integral_constant<E, e>, with the
+// additional static function `name()` that returns the stringified name of the
+// label.
+//
+// Eg:
+// enum class MyEnum { A, B };
+// struct AllMyEnum : EnumValuesAsTuple<AllMyEnum, MyEnum, 2> {
+// static constexpr absl::string_view Names[] = {"A", "B"};
+// };
+template <class Derived, class EnumType, size_t NumLabels>
+using EnumValuesAsTuple =
+ decltype(internal::makeEnumValueTuple<Derived, EnumType>(
+ std::make_index_sequence<NumLabels>{}));
+
+// Instantiates B<T0, T1, ..., TN> where <Ti...> are the combinations in the
+// cartesian product of `Tuples...`, and pass (arg0, ..., argN) as constructor
+// arguments where `(argi...)` are the combination in the cartesian product of
+// the runtime values of `A...`.
+// B<T...> requires:
+// - std::string name(args...): The name of the benchmark.
+// - void run(benchmark::State&, args...): The body of the benchmark.
+// It can also optionally provide:
+// - bool skip(args...): When `true`, skips the combination. Default is false.
+//
+// Returns int to facilitate registration. The return value is unspecified.
+template <template <class...> class B, class... Tuples, class... Args>
+int makeCartesianProductBenchmark(const Args&... A) {
+ std::vector<std::tuple<typename Args::value_type...> > V;
+ internal::allValueCombinations(V, std::tuple<>(), A...);
+ internal::makeBenchmarkImpl<B>(V, std::tuple<>(), Tuples()...);
+ return 0;
+}
+
+template <class B, class... Args>
+int makeCartesianProductBenchmark(const Args&... A) {
+ std::vector<std::tuple<typename Args::value_type...> > V;
+ internal::allValueCombinations(V, std::tuple<>(), A...);
+ internal::makeBenchmarkFromValues<B>(V);
+ return 0;
+}
+
+// When `opaque` is true, this function hides the runtime state of `value` from
+// the optimizer.
+// It returns `value`.
+template <class T>
+TEST_ALWAYS_INLINE inline T maybeOpaque(T value, bool opaque) {
+ if (opaque) benchmark::DoNotOptimize(value);
+ return value;
+}
+
Removed: libcxx/trunk/benchmarks/CartesianBenchmarks.hpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/CartesianBenchmarks.hpp?rev=369486&view=auto
==============================================================================
--- libcxx/trunk/benchmarks/CartesianBenchmarks.hpp (original)
+++ libcxx/trunk/benchmarks/CartesianBenchmarks.hpp (removed)
@@ -1,134 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-
-#include <string>
-#include <tuple>
-#include <type_traits>
-#include <vector>
-
-#include "benchmark/benchmark.h"
-#include "test_macros.h"
-
-namespace internal {
-
-template <class D, class E, size_t I>
-struct EnumValue : std::integral_constant<E, static_cast<E>(I)> {
- static std::string name() { return std::string("_") + D::Names[I]; }
-};
-
-template <class D, class E, size_t ...Idxs>
-constexpr auto makeEnumValueTuple(std::index_sequence<Idxs...>) {
- return std::make_tuple(EnumValue<D, E, Idxs>{}...);
-}
-
-template <class B>
-static auto skip(const B& Bench, int) -> decltype(Bench.skip()) {
- return Bench.skip();
-}
-template <class B>
-static auto skip(const B& Bench, char) {
- return false;
-}
-
-template <class B, class Args, size_t... Is>
-void makeBenchmarkFromValuesImpl(const Args& A, std::index_sequence<Is...>) {
- for (auto& V : A) {
- B Bench{std::get<Is>(V)...};
- if (!internal::skip(Bench, 0)) {
- benchmark::RegisterBenchmark(Bench.name().c_str(),
- [=](benchmark::State& S) { Bench.run(S); });
- }
- }
-}
-
-template <class B, class... Args>
-void makeBenchmarkFromValues(const std::vector<std::tuple<Args...> >& A) {
- makeBenchmarkFromValuesImpl<B>(A, std::index_sequence_for<Args...>());
-}
-
-template <template <class...> class B, class Args, class... U>
-void makeBenchmarkImpl(const Args& A, std::tuple<U...> t) {
- makeBenchmarkFromValues<B<U...> >(A);
-}
-
-template <template <class...> class B, class Args, class... U,
- class... T, class... Tuples>
-void makeBenchmarkImpl(const Args& A, std::tuple<U...>, std::tuple<T...>,
- Tuples... rest) {
- (internal::makeBenchmarkImpl<B>(A, std::tuple<U..., T>(), rest...), ...);
-}
-
-template <class R, class T>
-void allValueCombinations(R& Result, const T& Final) {
- return Result.push_back(Final);
-}
-
-template <class R, class T, class V, class... Vs>
-void allValueCombinations(R& Result, const T& Prev, const V& Value,
- const Vs&... Values) {
- for (const auto& E : Value) {
- allValueCombinations(Result, std::tuple_cat(Prev, std::make_tuple(E)),
- Values...);
- }
-}
-
-} // namespace internal
-
-// CRTP class that enables using enum types as a dimension for
-// makeCartesianProductBenchmark below.
-// The type passed to `B` will be a std::integral_constant<E, e>, with the
-// additional static function `name()` that returns the stringified name of the
-// label.
-//
-// Eg:
-// enum class MyEnum { A, B };
-// struct AllMyEnum : EnumValuesAsTuple<AllMyEnum, MyEnum, 2> {
-// static constexpr absl::string_view Names[] = {"A", "B"};
-// };
-template <class Derived, class EnumType, size_t NumLabels>
-using EnumValuesAsTuple =
- decltype(internal::makeEnumValueTuple<Derived, EnumType>(
- std::make_index_sequence<NumLabels>{}));
-
-// Instantiates B<T0, T1, ..., TN> where <Ti...> are the combinations in the
-// cartesian product of `Tuples...`, and pass (arg0, ..., argN) as constructor
-// arguments where `(argi...)` are the combination in the cartesian product of
-// the runtime values of `A...`.
-// B<T...> requires:
-// - std::string name(args...): The name of the benchmark.
-// - void run(benchmark::State&, args...): The body of the benchmark.
-// It can also optionally provide:
-// - bool skip(args...): When `true`, skips the combination. Default is false.
-//
-// Returns int to facilitate registration. The return value is unspecified.
-template <template <class...> class B, class... Tuples, class... Args>
-int makeCartesianProductBenchmark(const Args&... A) {
- std::vector<std::tuple<typename Args::value_type...> > V;
- internal::allValueCombinations(V, std::tuple<>(), A...);
- internal::makeBenchmarkImpl<B>(V, std::tuple<>(), Tuples()...);
- return 0;
-}
-
-template <class B, class... Args>
-int makeCartesianProductBenchmark(const Args&... A) {
- std::vector<std::tuple<typename Args::value_type...> > V;
- internal::allValueCombinations(V, std::tuple<>(), A...);
- internal::makeBenchmarkFromValues<B>(V);
- return 0;
-}
-
-// When `opaque` is true, this function hides the runtime state of `value` from
-// the optimizer.
-// It returns `value`.
-template <class T>
-TEST_ALWAYS_INLINE inline T maybeOpaque(T value, bool opaque) {
- if (opaque) benchmark::DoNotOptimize(value);
- return value;
-}
-
Added: libcxx/trunk/benchmarks/ContainerBenchmarks.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/ContainerBenchmarks.h?rev=369487&view=auto
==============================================================================
--- libcxx/trunk/benchmarks/ContainerBenchmarks.h (added)
+++ libcxx/trunk/benchmarks/ContainerBenchmarks.h Tue Aug 20 18:59:12 2019
@@ -0,0 +1,140 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef BENCHMARK_CONTAINER_BENCHMARKS_H
+#define BENCHMARK_CONTAINER_BENCHMARKS_H
+
+#include <cassert>
+
+#include "Utilities.h"
+#include "benchmark/benchmark.h"
+
+namespace ContainerBenchmarks {
+
+template <class Container>
+void BM_ConstructSize(benchmark::State& st, Container) {
+ auto size = st.range(0);
+ for (auto _ : st) {
+ Container c(size);
+ DoNotOptimizeData(c);
+ }
+}
+
+template <class Container>
+void BM_ConstructSizeValue(benchmark::State& st, Container, typename Container::value_type const& val) {
+ const auto size = st.range(0);
+ for (auto _ : st) {
+ Container c(size, val);
+ DoNotOptimizeData(c);
+ }
+}
+
+template <class Container, class GenInputs>
+void BM_ConstructIterIter(benchmark::State& st, Container, GenInputs gen) {
+ auto in = gen(st.range(0));
+ const auto begin = in.begin();
+ const auto end = in.end();
+ benchmark::DoNotOptimize(&in);
+ while (st.KeepRunning()) {
+ Container c(begin, end);
+ DoNotOptimizeData(c);
+ }
+}
+
+template <class Container, class GenInputs>
+void BM_InsertValue(benchmark::State& st, Container c, GenInputs gen) {
+ auto in = gen(st.range(0));
+ const auto end = in.end();
+ while (st.KeepRunning()) {
+ c.clear();
+ for (auto it = in.begin(); it != end; ++it) {
+ benchmark::DoNotOptimize(&(*c.insert(*it).first));
+ }
+ benchmark::ClobberMemory();
+ }
+}
+
+template <class Container, class GenInputs>
+void BM_InsertValueRehash(benchmark::State& st, Container c, GenInputs gen) {
+ auto in = gen(st.range(0));
+ const auto end = in.end();
+ while (st.KeepRunning()) {
+ c.clear();
+ c.rehash(16);
+ for (auto it = in.begin(); it != end; ++it) {
+ benchmark::DoNotOptimize(&(*c.insert(*it).first));
+ }
+ benchmark::ClobberMemory();
+ }
+}
+
+
+template <class Container, class GenInputs>
+void BM_InsertDuplicate(benchmark::State& st, Container c, GenInputs gen) {
+ auto in = gen(st.range(0));
+ const auto end = in.end();
+ c.insert(in.begin(), in.end());
+ benchmark::DoNotOptimize(&c);
+ benchmark::DoNotOptimize(&in);
+ while (st.KeepRunning()) {
+ for (auto it = in.begin(); it != end; ++it) {
+ benchmark::DoNotOptimize(&(*c.insert(*it).first));
+ }
+ benchmark::ClobberMemory();
+ }
+}
+
+
+template <class Container, class GenInputs>
+void BM_EmplaceDuplicate(benchmark::State& st, Container c, GenInputs gen) {
+ auto in = gen(st.range(0));
+ const auto end = in.end();
+ c.insert(in.begin(), in.end());
+ benchmark::DoNotOptimize(&c);
+ benchmark::DoNotOptimize(&in);
+ while (st.KeepRunning()) {
+ for (auto it = in.begin(); it != end; ++it) {
+ benchmark::DoNotOptimize(&(*c.emplace(*it).first));
+ }
+ benchmark::ClobberMemory();
+ }
+}
+
+template <class Container, class GenInputs>
+static void BM_Find(benchmark::State& st, Container c, GenInputs gen) {
+ auto in = gen(st.range(0));
+ c.insert(in.begin(), in.end());
+ benchmark::DoNotOptimize(&(*c.begin()));
+ const auto end = in.data() + in.size();
+ while (st.KeepRunning()) {
+ for (auto it = in.data(); it != end; ++it) {
+ benchmark::DoNotOptimize(&(*c.find(*it)));
+ }
+ benchmark::ClobberMemory();
+ }
+}
+
+template <class Container, class GenInputs>
+static void BM_FindRehash(benchmark::State& st, Container c, GenInputs gen) {
+ c.rehash(8);
+ auto in = gen(st.range(0));
+ c.insert(in.begin(), in.end());
+ benchmark::DoNotOptimize(&(*c.begin()));
+ const auto end = in.data() + in.size();
+ while (st.KeepRunning()) {
+ for (auto it = in.data(); it != end; ++it) {
+ benchmark::DoNotOptimize(&(*c.find(*it)));
+ }
+ benchmark::ClobberMemory();
+ }
+}
+
+} // end namespace ContainerBenchmarks
+
+#endif // BENCHMARK_CONTAINER_BENCHMARKS_H
Removed: libcxx/trunk/benchmarks/ContainerBenchmarks.hpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/ContainerBenchmarks.hpp?rev=369486&view=auto
==============================================================================
--- libcxx/trunk/benchmarks/ContainerBenchmarks.hpp (original)
+++ libcxx/trunk/benchmarks/ContainerBenchmarks.hpp (removed)
@@ -1,140 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef BENCHMARK_CONTAINER_BENCHMARKS_HPP
-#define BENCHMARK_CONTAINER_BENCHMARKS_HPP
-
-#include <cassert>
-
-#include "Utilities.hpp"
-#include "benchmark/benchmark.h"
-
-namespace ContainerBenchmarks {
-
-template <class Container>
-void BM_ConstructSize(benchmark::State& st, Container) {
- auto size = st.range(0);
- for (auto _ : st) {
- Container c(size);
- DoNotOptimizeData(c);
- }
-}
-
-template <class Container>
-void BM_ConstructSizeValue(benchmark::State& st, Container, typename Container::value_type const& val) {
- const auto size = st.range(0);
- for (auto _ : st) {
- Container c(size, val);
- DoNotOptimizeData(c);
- }
-}
-
-template <class Container, class GenInputs>
-void BM_ConstructIterIter(benchmark::State& st, Container, GenInputs gen) {
- auto in = gen(st.range(0));
- const auto begin = in.begin();
- const auto end = in.end();
- benchmark::DoNotOptimize(&in);
- while (st.KeepRunning()) {
- Container c(begin, end);
- DoNotOptimizeData(c);
- }
-}
-
-template <class Container, class GenInputs>
-void BM_InsertValue(benchmark::State& st, Container c, GenInputs gen) {
- auto in = gen(st.range(0));
- const auto end = in.end();
- while (st.KeepRunning()) {
- c.clear();
- for (auto it = in.begin(); it != end; ++it) {
- benchmark::DoNotOptimize(&(*c.insert(*it).first));
- }
- benchmark::ClobberMemory();
- }
-}
-
-template <class Container, class GenInputs>
-void BM_InsertValueRehash(benchmark::State& st, Container c, GenInputs gen) {
- auto in = gen(st.range(0));
- const auto end = in.end();
- while (st.KeepRunning()) {
- c.clear();
- c.rehash(16);
- for (auto it = in.begin(); it != end; ++it) {
- benchmark::DoNotOptimize(&(*c.insert(*it).first));
- }
- benchmark::ClobberMemory();
- }
-}
-
-
-template <class Container, class GenInputs>
-void BM_InsertDuplicate(benchmark::State& st, Container c, GenInputs gen) {
- auto in = gen(st.range(0));
- const auto end = in.end();
- c.insert(in.begin(), in.end());
- benchmark::DoNotOptimize(&c);
- benchmark::DoNotOptimize(&in);
- while (st.KeepRunning()) {
- for (auto it = in.begin(); it != end; ++it) {
- benchmark::DoNotOptimize(&(*c.insert(*it).first));
- }
- benchmark::ClobberMemory();
- }
-}
-
-
-template <class Container, class GenInputs>
-void BM_EmplaceDuplicate(benchmark::State& st, Container c, GenInputs gen) {
- auto in = gen(st.range(0));
- const auto end = in.end();
- c.insert(in.begin(), in.end());
- benchmark::DoNotOptimize(&c);
- benchmark::DoNotOptimize(&in);
- while (st.KeepRunning()) {
- for (auto it = in.begin(); it != end; ++it) {
- benchmark::DoNotOptimize(&(*c.emplace(*it).first));
- }
- benchmark::ClobberMemory();
- }
-}
-
-template <class Container, class GenInputs>
-static void BM_Find(benchmark::State& st, Container c, GenInputs gen) {
- auto in = gen(st.range(0));
- c.insert(in.begin(), in.end());
- benchmark::DoNotOptimize(&(*c.begin()));
- const auto end = in.data() + in.size();
- while (st.KeepRunning()) {
- for (auto it = in.data(); it != end; ++it) {
- benchmark::DoNotOptimize(&(*c.find(*it)));
- }
- benchmark::ClobberMemory();
- }
-}
-
-template <class Container, class GenInputs>
-static void BM_FindRehash(benchmark::State& st, Container c, GenInputs gen) {
- c.rehash(8);
- auto in = gen(st.range(0));
- c.insert(in.begin(), in.end());
- benchmark::DoNotOptimize(&(*c.begin()));
- const auto end = in.data() + in.size();
- while (st.KeepRunning()) {
- for (auto it = in.data(); it != end; ++it) {
- benchmark::DoNotOptimize(&(*c.find(*it)));
- }
- benchmark::ClobberMemory();
- }
-}
-
-} // end namespace ContainerBenchmarks
-
-#endif // BENCHMARK_CONTAINER_BENCHMARKS_HPP
Added: libcxx/trunk/benchmarks/GenerateInput.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/GenerateInput.h?rev=369487&view=auto
==============================================================================
--- libcxx/trunk/benchmarks/GenerateInput.h (added)
+++ libcxx/trunk/benchmarks/GenerateInput.h Tue Aug 20 18:59:12 2019
@@ -0,0 +1,144 @@
+#ifndef BENCHMARK_GENERATE_INPUT_H
+#define BENCHMARK_GENERATE_INPUT_H
+
+#include <algorithm>
+#include <random>
+#include <vector>
+#include <string>
+#include <climits>
+#include <cstddef>
+
+static const char Letters[] = {
+ '0','1','2','3','4',
+ '5','6','7','8','9',
+ 'A','B','C','D','E','F',
+ 'G','H','I','J','K',
+ 'L','M','N','O','P',
+ 'Q','R','S','T','U',
+ 'V','W','X','Y','Z',
+ 'a','b','c','d','e','f',
+ 'g','h','i','j','k',
+ 'l','m','n','o','p',
+ 'q','r','s','t','u',
+ 'v','w','x','y','z'
+};
+static const std::size_t LettersSize = sizeof(Letters);
+
+inline std::default_random_engine& getRandomEngine() {
+ static std::default_random_engine RandEngine(std::random_device{}());
+ return RandEngine;
+}
+
+
+inline char getRandomChar() {
+ std::uniform_int_distribution<> LettersDist(0, LettersSize-1);
+ return Letters[LettersDist(getRandomEngine())];
+}
+
+template <class IntT>
+inline IntT getRandomInteger(IntT Min = 0,
+ IntT Max = std::numeric_limits<IntT>::max()) {
+ std::uniform_int_distribution<IntT> dist(Min, Max);
+ return dist(getRandomEngine());
+}
+
+inline std::string getRandomString(std::size_t Len) {
+ std::string str(Len, 0);
+ std::generate_n(str.begin(), Len, &getRandomChar);
+ return str;
+}
+
+template <class IntT>
+inline std::vector<IntT> getDuplicateIntegerInputs(size_t N) {
+ std::vector<IntT> inputs(N, static_cast<IntT>(-1));
+ return inputs;
+}
+
+template <class IntT>
+inline std::vector<IntT> getSortedIntegerInputs(size_t N) {
+ std::vector<IntT> inputs;
+ for (size_t i=0; i < N; i += 1)
+ inputs.push_back(i);
+ return inputs;
+}
+
+template <class IntT>
+std::vector<IntT> getSortedLargeIntegerInputs(size_t N) {
+ std::vector<IntT> inputs;
+ for (size_t i=0; i < N; ++i) {
+ inputs.push_back(i + N);
+ }
+ return inputs;
+}
+
+template <class IntT>
+std::vector<IntT> getSortedTopBitsIntegerInputs(size_t N) {
+ std::vector<IntT> inputs = getSortedIntegerInputs<IntT>(N);
+ for (auto& E : inputs) E <<= ((sizeof(IntT) / 2) * CHAR_BIT);
+ return inputs;
+}
+
+template <class IntT>
+inline std::vector<IntT> getReverseSortedIntegerInputs(size_t N) {
+ std::vector<IntT> inputs;
+ std::size_t i = N;
+ while (i > 0) {
+ --i;
+ inputs.push_back(i);
+ }
+ return inputs;
+}
+
+template <class IntT>
+std::vector<IntT> getPipeOrganIntegerInputs(size_t N) {
+ std::vector<IntT> v; v.reserve(N);
+ for (size_t i = 0; i < N/2; ++i) v.push_back(i);
+ for (size_t i = N/2; i < N; ++i) v.push_back(N - i);
+ return v;
+}
+
+
+template <class IntT>
+std::vector<IntT> getRandomIntegerInputs(size_t N) {
+ std::vector<IntT> inputs;
+ for (size_t i=0; i < N; ++i) {
+ inputs.push_back(getRandomInteger<IntT>());
+ }
+ return inputs;
+}
+
+inline std::vector<std::string> getDuplicateStringInputs(size_t N) {
+ std::vector<std::string> inputs(N, getRandomString(1024));
+ return inputs;
+}
+
+inline std::vector<std::string> getRandomStringInputs(size_t N) {
+ std::vector<std::string> inputs;
+ for (size_t i=0; i < N; ++i) {
+ inputs.push_back(getRandomString(1024));
+ }
+ return inputs;
+}
+
+inline std::vector<std::string> getSortedStringInputs(size_t N) {
+ std::vector<std::string> inputs = getRandomStringInputs(N);
+ std::sort(inputs.begin(), inputs.end());
+ return inputs;
+}
+
+inline std::vector<std::string> getReverseSortedStringInputs(size_t N) {
+ std::vector<std::string> inputs = getSortedStringInputs(N);
+ std::reverse(inputs.begin(), inputs.end());
+ return inputs;
+}
+
+inline std::vector<const char*> getRandomCStringInputs(size_t N) {
+ static std::vector<std::string> inputs = getRandomStringInputs(N);
+ std::vector<const char*> cinputs;
+ for (auto const& str : inputs)
+ cinputs.push_back(str.c_str());
+ return cinputs;
+}
+
+
+#endif // BENCHMARK_GENERATE_INPUT_H
Removed: libcxx/trunk/benchmarks/GenerateInput.hpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/GenerateInput.hpp?rev=369486&view=auto
==============================================================================
--- libcxx/trunk/benchmarks/GenerateInput.hpp (original)
+++ libcxx/trunk/benchmarks/GenerateInput.hpp (removed)
@@ -1,144 +0,0 @@
-#ifndef BENCHMARK_GENERATE_INPUT_HPP
-#define BENCHMARK_GENERATE_INPUT_HPP
-
-#include <algorithm>
-#include <random>
-#include <vector>
-#include <string>
-#include <climits>
-#include <cstddef>
-
-static const char Letters[] = {
- '0','1','2','3','4',
- '5','6','7','8','9',
- 'A','B','C','D','E','F',
- 'G','H','I','J','K',
- 'L','M','N','O','P',
- 'Q','R','S','T','U',
- 'V','W','X','Y','Z',
- 'a','b','c','d','e','f',
- 'g','h','i','j','k',
- 'l','m','n','o','p',
- 'q','r','s','t','u',
- 'v','w','x','y','z'
-};
-static const std::size_t LettersSize = sizeof(Letters);
-
-inline std::default_random_engine& getRandomEngine() {
- static std::default_random_engine RandEngine(std::random_device{}());
- return RandEngine;
-}
-
-
-inline char getRandomChar() {
- std::uniform_int_distribution<> LettersDist(0, LettersSize-1);
- return Letters[LettersDist(getRandomEngine())];
-}
-
-template <class IntT>
-inline IntT getRandomInteger(IntT Min = 0,
- IntT Max = std::numeric_limits<IntT>::max()) {
- std::uniform_int_distribution<IntT> dist(Min, Max);
- return dist(getRandomEngine());
-}
-
-inline std::string getRandomString(std::size_t Len) {
- std::string str(Len, 0);
- std::generate_n(str.begin(), Len, &getRandomChar);
- return str;
-}
-
-template <class IntT>
-inline std::vector<IntT> getDuplicateIntegerInputs(size_t N) {
- std::vector<IntT> inputs(N, static_cast<IntT>(-1));
- return inputs;
-}
-
-template <class IntT>
-inline std::vector<IntT> getSortedIntegerInputs(size_t N) {
- std::vector<IntT> inputs;
- for (size_t i=0; i < N; i += 1)
- inputs.push_back(i);
- return inputs;
-}
-
-template <class IntT>
-std::vector<IntT> getSortedLargeIntegerInputs(size_t N) {
- std::vector<IntT> inputs;
- for (size_t i=0; i < N; ++i) {
- inputs.push_back(i + N);
- }
- return inputs;
-}
-
-template <class IntT>
-std::vector<IntT> getSortedTopBitsIntegerInputs(size_t N) {
- std::vector<IntT> inputs = getSortedIntegerInputs<IntT>(N);
- for (auto& E : inputs) E <<= ((sizeof(IntT) / 2) * CHAR_BIT);
- return inputs;
-}
-
-template <class IntT>
-inline std::vector<IntT> getReverseSortedIntegerInputs(size_t N) {
- std::vector<IntT> inputs;
- std::size_t i = N;
- while (i > 0) {
- --i;
- inputs.push_back(i);
- }
- return inputs;
-}
-
-template <class IntT>
-std::vector<IntT> getPipeOrganIntegerInputs(size_t N) {
- std::vector<IntT> v; v.reserve(N);
- for (size_t i = 0; i < N/2; ++i) v.push_back(i);
- for (size_t i = N/2; i < N; ++i) v.push_back(N - i);
- return v;
-}
-
-
-template <class IntT>
-std::vector<IntT> getRandomIntegerInputs(size_t N) {
- std::vector<IntT> inputs;
- for (size_t i=0; i < N; ++i) {
- inputs.push_back(getRandomInteger<IntT>());
- }
- return inputs;
-}
-
-inline std::vector<std::string> getDuplicateStringInputs(size_t N) {
- std::vector<std::string> inputs(N, getRandomString(1024));
- return inputs;
-}
-
-inline std::vector<std::string> getRandomStringInputs(size_t N) {
- std::vector<std::string> inputs;
- for (size_t i=0; i < N; ++i) {
- inputs.push_back(getRandomString(1024));
- }
- return inputs;
-}
-
-inline std::vector<std::string> getSortedStringInputs(size_t N) {
- std::vector<std::string> inputs = getRandomStringInputs(N);
- std::sort(inputs.begin(), inputs.end());
- return inputs;
-}
-
-inline std::vector<std::string> getReverseSortedStringInputs(size_t N) {
- std::vector<std::string> inputs = getSortedStringInputs(N);
- std::reverse(inputs.begin(), inputs.end());
- return inputs;
-}
-
-inline std::vector<const char*> getRandomCStringInputs(size_t N) {
- static std::vector<std::string> inputs = getRandomStringInputs(N);
- std::vector<const char*> cinputs;
- for (auto const& str : inputs)
- cinputs.push_back(str.c_str());
- return cinputs;
-}
-
-
-#endif // BENCHMARK_GENERATE_INPUT_HPP
Added: libcxx/trunk/benchmarks/Utilities.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/Utilities.h?rev=369487&view=auto
==============================================================================
--- libcxx/trunk/benchmarks/Utilities.h (added)
+++ libcxx/trunk/benchmarks/Utilities.h Tue Aug 20 18:59:12 2019
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef BENCHMARK_UTILITIES_H
+#define BENCHMARK_UTILITIES_H
+
+#include <cassert>
+#include <type_traits>
+
+#include "benchmark/benchmark.h"
+
+namespace UtilitiesInternal {
+ template <class Container>
+ auto HaveDataImpl(int) -> decltype((std::declval<Container&>().data(), std::true_type{}));
+ template <class Container>
+ auto HaveDataImpl(long) -> std::false_type;
+ template <class T>
+ using HasData = decltype(HaveDataImpl<T>(0));
+} // namespace UtilitiesInternal
+
+template <class Container, std::enable_if_t<UtilitiesInternal::HasData<Container>::value>* = nullptr>
+void DoNotOptimizeData(Container &c) { benchmark::DoNotOptimize(c.data()); }
+template <class Container, std::enable_if_t<!UtilitiesInternal::HasData<Container>::value>* = nullptr>
+void DoNotOptimizeData(Container &c) { benchmark::DoNotOptimize(&c); }
+
+
+#endif // BENCHMARK_UTILITIES_H
Removed: libcxx/trunk/benchmarks/Utilities.hpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/Utilities.hpp?rev=369486&view=auto
==============================================================================
--- libcxx/trunk/benchmarks/Utilities.hpp (original)
+++ libcxx/trunk/benchmarks/Utilities.hpp (removed)
@@ -1,33 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef BENCHMARK_UTILITIES_HPP
-#define BENCHMARK_UTILITIES_HPP
-
-#include <cassert>
-#include <type_traits>
-
-#include "benchmark/benchmark.h"
-
-namespace UtilitiesInternal {
- template <class Container>
- auto HaveDataImpl(int) -> decltype((std::declval<Container&>().data(), std::true_type{}));
- template <class Container>
- auto HaveDataImpl(long) -> std::false_type;
- template <class T>
- using HasData = decltype(HaveDataImpl<T>(0));
-} // namespace UtilitiesInternal
-
-template <class Container, std::enable_if_t<UtilitiesInternal::HasData<Container>::value>* = nullptr>
-void DoNotOptimizeData(Container &c) { benchmark::DoNotOptimize(c.data()); }
-template <class Container, std::enable_if_t<!UtilitiesInternal::HasData<Container>::value>* = nullptr>
-void DoNotOptimizeData(Container &c) { benchmark::DoNotOptimize(&c); }
-
-
-#endif // BENCHMARK_UTILITIES_HPP
Modified: libcxx/trunk/benchmarks/algorithms.bench.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/algorithms.bench.cpp?rev=369487&r1=369486&r2=369487&view=diff
==============================================================================
--- libcxx/trunk/benchmarks/algorithms.bench.cpp (original)
+++ libcxx/trunk/benchmarks/algorithms.bench.cpp Tue Aug 20 18:59:12 2019
@@ -7,8 +7,8 @@
#include <utility>
#include <vector>
-#include "CartesianBenchmarks.hpp"
-#include "GenerateInput.hpp"
+#include "CartesianBenchmarks.h"
+#include "GenerateInput.h"
#include "benchmark/benchmark.h"
#include "test_macros.h"
Modified: libcxx/trunk/benchmarks/algorithms.partition_point.bench.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/algorithms.partition_point.bench.cpp?rev=369487&r1=369486&r2=369487&view=diff
==============================================================================
--- libcxx/trunk/benchmarks/algorithms.partition_point.bench.cpp (original)
+++ libcxx/trunk/benchmarks/algorithms.partition_point.bench.cpp Tue Aug 20 18:59:12 2019
@@ -7,8 +7,8 @@
#include "benchmark/benchmark.h"
-#include "CartesianBenchmarks.hpp"
-#include "GenerateInput.hpp"
+#include "CartesianBenchmarks.h"
+#include "GenerateInput.h"
namespace {
Modified: libcxx/trunk/benchmarks/deque.bench.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/deque.bench.cpp?rev=369487&r1=369486&r2=369487&view=diff
==============================================================================
--- libcxx/trunk/benchmarks/deque.bench.cpp (original)
+++ libcxx/trunk/benchmarks/deque.bench.cpp Tue Aug 20 18:59:12 2019
@@ -11,8 +11,8 @@
#include "benchmark/benchmark.h"
-#include "ContainerBenchmarks.hpp"
-#include "GenerateInput.hpp"
+#include "ContainerBenchmarks.h"
+#include "GenerateInput.h"
using namespace ContainerBenchmarks;
Modified: libcxx/trunk/benchmarks/filesystem.bench.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/filesystem.bench.cpp?rev=369487&r1=369486&r2=369487&view=diff
==============================================================================
--- libcxx/trunk/benchmarks/filesystem.bench.cpp (original)
+++ libcxx/trunk/benchmarks/filesystem.bench.cpp Tue Aug 20 18:59:12 2019
@@ -1,5 +1,5 @@
#include "benchmark/benchmark.h"
-#include "GenerateInput.hpp"
+#include "GenerateInput.h"
#include "test_iterators.h"
#include "filesystem_include.h"
Modified: libcxx/trunk/benchmarks/function.bench.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/function.bench.cpp?rev=369487&r1=369486&r2=369487&view=diff
==============================================================================
--- libcxx/trunk/benchmarks/function.bench.cpp (original)
+++ libcxx/trunk/benchmarks/function.bench.cpp Tue Aug 20 18:59:12 2019
@@ -11,7 +11,7 @@
#include <memory>
#include <string>
-#include "CartesianBenchmarks.hpp"
+#include "CartesianBenchmarks.h"
#include "benchmark/benchmark.h"
#include "test_macros.h"
Modified: libcxx/trunk/benchmarks/ordered_set.bench.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/ordered_set.bench.cpp?rev=369487&r1=369486&r2=369487&view=diff
==============================================================================
--- libcxx/trunk/benchmarks/ordered_set.bench.cpp (original)
+++ libcxx/trunk/benchmarks/ordered_set.bench.cpp Tue Aug 20 18:59:12 2019
@@ -14,7 +14,7 @@
#include <string>
#include <vector>
-#include "CartesianBenchmarks.hpp"
+#include "CartesianBenchmarks.h"
#include "benchmark/benchmark.h"
#include "test_macros.h"
Modified: libcxx/trunk/benchmarks/string.bench.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/string.bench.cpp?rev=369487&r1=369486&r2=369487&view=diff
==============================================================================
--- libcxx/trunk/benchmarks/string.bench.cpp (original)
+++ libcxx/trunk/benchmarks/string.bench.cpp Tue Aug 20 18:59:12 2019
@@ -3,8 +3,8 @@
#include <new>
#include <vector>
-#include "CartesianBenchmarks.hpp"
-#include "GenerateInput.hpp"
+#include "CartesianBenchmarks.h"
+#include "GenerateInput.h"
#include "benchmark/benchmark.h"
#include "test_macros.h"
Modified: libcxx/trunk/benchmarks/unordered_set_operations.bench.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/unordered_set_operations.bench.cpp?rev=369487&r1=369486&r2=369487&view=diff
==============================================================================
--- libcxx/trunk/benchmarks/unordered_set_operations.bench.cpp (original)
+++ libcxx/trunk/benchmarks/unordered_set_operations.bench.cpp Tue Aug 20 18:59:12 2019
@@ -7,8 +7,8 @@
#include "benchmark/benchmark.h"
-#include "ContainerBenchmarks.hpp"
-#include "GenerateInput.hpp"
+#include "ContainerBenchmarks.h"
+#include "GenerateInput.h"
#include "test_macros.h"
using namespace ContainerBenchmarks;
Modified: libcxx/trunk/benchmarks/vector_operations.bench.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/vector_operations.bench.cpp?rev=369487&r1=369486&r2=369487&view=diff
==============================================================================
--- libcxx/trunk/benchmarks/vector_operations.bench.cpp (original)
+++ libcxx/trunk/benchmarks/vector_operations.bench.cpp Tue Aug 20 18:59:12 2019
@@ -6,8 +6,8 @@
#include "benchmark/benchmark.h"
-#include "ContainerBenchmarks.hpp"
-#include "GenerateInput.hpp"
+#include "ContainerBenchmarks.h"
+#include "GenerateInput.h"
using namespace ContainerBenchmarks;
More information about the libcxx-commits
mailing list