From: Samuel Benzaquen Date: Fri, 12 Oct 2018 21:01:15 +0000 (+0000) Subject: Add benchmarks for std::function. X-Git-Tag: llvmorg-8.0.0-rc1~6619 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0e6a833e468d5bcb9e66d29e2cc61546c35b33f0;p=platform%2Fupstream%2Fllvm.git 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 llvm-svn: 344415 --- diff --git a/libcxx/benchmarks/CartesianBenchmarks.hpp b/libcxx/benchmarks/CartesianBenchmarks.hpp new file mode 100644 index 0000000..7cd13a0 --- /dev/null +++ b/libcxx/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