From 11b8a464982ff7b04323638acf70388e9fe7ff0e Mon Sep 17 00:00:00 2001 From: Samuel Benzaquen Date: Fri, 12 Oct 2018 21:01:15 +0000 Subject: [PATCH] Add benchmarks for std::function. Summary: Benchmarks for construct, copy, move, swap, destroy and invoke, with 8 different input states. For the cases that matter, it tests with and without allowing constant value propagation from construction into the operation tested. This also adds helper functions to generate the cartesian product of different configurations and generate benchmarks for all of them. Reviewers: EricWF Subscribers: christof, ldionne, libcxx-commits Differential Revision: https://reviews.llvm.org/D53087 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344415 91177308-0d34-0410-b5e6-96231b3b80d8 --- benchmarks/CartesianBenchmarks.hpp | 92 ++++++++++++ benchmarks/function.bench.cpp | 232 +++++++++++++++++++++++++++++ 2 files changed, 324 insertions(+) create mode 100644 benchmarks/CartesianBenchmarks.hpp create mode 100644 benchmarks/function.bench.cpp diff --git a/benchmarks/CartesianBenchmarks.hpp b/benchmarks/CartesianBenchmarks.hpp new file mode 100644 index 000000000..7cd13a052 --- /dev/null +++ b/benchmarks/CartesianBenchmarks.hpp @@ -0,0 +1,92 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + + +#include +#include +#include + +#include "benchmark/benchmark.h" +#include "test_macros.h" + +namespace internal { + +template +struct EnumValue : std::integral_constant(I)> { + static std::string name() { return std::string("_") + D::Names[I]; } +}; + +template +constexpr auto makeEnumValueTuple(std::index_sequence) { + return std::make_tuple(EnumValue{}...); +} + +template +static auto skip(int) -> decltype(T::skip()) { + return T::skip(); +} +template +static bool skip(char) { + return false; +} + +template