mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:43:36 +01:00
0f55045526
This patch pulls google/benchmark v1.4.1 into the LLVM tree so that any project could use it for benchmark generation. A dummy benchmark is added to `llvm/benchmarks/DummyYAML.cpp` to validate the correctness of the build process. The current version does not utilize LLVM LNT and LLVM CMake infrastructure, but that might be sufficient for most users. Two introduced CMake variables: * `LLVM_INCLUDE_BENCHMARKS` (`ON` by default) generates benchmark targets * `LLVM_BUILD_BENCHMARKS` (`OFF` by default) adds generated benchmark targets to the list of default LLVM targets (i.e. if `ON` benchmarks will be built upon standard build invocation, e.g. `ninja` or `make` with no specific targets) List of modifications: * `BENCHMARK_ENABLE_TESTING` is disabled * `BENCHMARK_ENABLE_EXCEPTIONS` is disabled * `BENCHMARK_ENABLE_INSTALL` is disabled * `BENCHMARK_ENABLE_GTEST_TESTS` is disabled * `BENCHMARK_DOWNLOAD_DEPENDENCIES` is disabled Original discussion can be found here: http://lists.llvm.org/pipermail/llvm-dev/2018-August/125023.html Reviewed by: dberris, lebedev.ri Subscribers: ilya-biryukov, ioeric, EricWF, lebedev.ri, srhines, dschuff, mgorny, krytarowski, fedor.sergeev, mgrang, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D50894 llvm-svn: 340809
64 lines
1.6 KiB
C++
64 lines
1.6 KiB
C++
#undef NDEBUG
|
|
#include <cassert>
|
|
#include <cstddef>
|
|
|
|
#include "benchmark/benchmark.h"
|
|
|
|
#if __cplusplus >= 201103L
|
|
#error C++11 or greater detected. Should be C++03.
|
|
#endif
|
|
|
|
#ifdef BENCHMARK_HAS_CXX11
|
|
#error C++11 or greater detected by the library. BENCHMARK_HAS_CXX11 is defined.
|
|
#endif
|
|
|
|
void BM_empty(benchmark::State& state) {
|
|
while (state.KeepRunning()) {
|
|
volatile std::size_t x = state.iterations();
|
|
((void)x);
|
|
}
|
|
}
|
|
BENCHMARK(BM_empty);
|
|
|
|
// The new C++11 interface for args/ranges requires initializer list support.
|
|
// Therefore we provide the old interface to support C++03.
|
|
void BM_old_arg_range_interface(benchmark::State& state) {
|
|
assert((state.range(0) == 1 && state.range(1) == 2) ||
|
|
(state.range(0) == 5 && state.range(1) == 6));
|
|
while (state.KeepRunning()) {
|
|
}
|
|
}
|
|
BENCHMARK(BM_old_arg_range_interface)->ArgPair(1, 2)->RangePair(5, 5, 6, 6);
|
|
|
|
template <class T, class U>
|
|
void BM_template2(benchmark::State& state) {
|
|
BM_empty(state);
|
|
}
|
|
BENCHMARK_TEMPLATE2(BM_template2, int, long);
|
|
|
|
template <class T>
|
|
void BM_template1(benchmark::State& state) {
|
|
BM_empty(state);
|
|
}
|
|
BENCHMARK_TEMPLATE(BM_template1, long);
|
|
BENCHMARK_TEMPLATE1(BM_template1, int);
|
|
|
|
template <class T>
|
|
struct BM_Fixture : public ::benchmark::Fixture {
|
|
};
|
|
|
|
BENCHMARK_TEMPLATE_F(BM_Fixture, BM_template1, long)(benchmark::State& state) {
|
|
BM_empty(state);
|
|
}
|
|
BENCHMARK_TEMPLATE1_F(BM_Fixture, BM_template2, int)(benchmark::State& state) {
|
|
BM_empty(state);
|
|
}
|
|
|
|
void BM_counters(benchmark::State& state) {
|
|
BM_empty(state);
|
|
state.counters["Foo"] = 2;
|
|
}
|
|
BENCHMARK(BM_counters);
|
|
|
|
BENCHMARK_MAIN();
|