Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
hist_benchmark_regular.cxx
Go to the documentation of this file.
2
3#include <benchmark/benchmark.h>
4
5#include <cstddef>
6#include <random>
7#include <vector>
8
9struct RRegularAxis : public benchmark::Fixture {
10 // The axis is stored and constructed in the fixture to avoid compiler optimizations in the benchmark body taking
11 // advantage of the (constant) constructor parameters.
13 std::vector<double> fNumbers;
14
15 // Avoid GCC warning
16 using benchmark::Fixture::SetUp;
17 void SetUp(benchmark::State &state) final
18 {
19 std::mt19937 gen;
20 std::uniform_real_distribution<> dis;
21 fNumbers.resize(static_cast<std::size_t>(state.range(0)));
22 for (std::size_t i = 0; i < fNumbers.size(); i++) {
23 fNumbers[i] = dis(gen);
24 }
25 }
26};
27
28BENCHMARK_DEFINE_F(RRegularAxis, ComputeLinearizedIndex)(benchmark::State &state)
29{
30 for (auto _ : state) {
31 for (double number : fNumbers) {
32 benchmark::DoNotOptimize(axis.ComputeLinearizedIndex(number));
33 }
34 }
35}
36BENCHMARK_REGISTER_F(RRegularAxis, ComputeLinearizedIndex)->Range(0, 32768);
37
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define _(A, B)
Definition cfortran.h:108
A regular axis with equidistant bins in the interval .
BENCHMARK_DEFINE_F(RRegularAxis, ComputeLinearizedIndex)(benchmark
BENCHMARK_MAIN()
BENCHMARK_REGISTER_F(RRegularAxis, ComputeLinearizedIndex) -> Range(0, 32768)
ROOT::Experimental::RRegularAxis axis
void SetUp(benchmark::State &state) final
std::vector< double > fNumbers