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 <random>
6#include <vector>
7
8struct RRegularAxis : public benchmark::Fixture {
9 // The axis is stored and constructed in the fixture to avoid compiler optimizations in the benchmark body taking
10 // advantage of the (constant) constructor parameters.
12 std::vector<double> fNumbers;
13
14 // Avoid GCC warning
15 using benchmark::Fixture::SetUp;
16 void SetUp(benchmark::State &state) final
17 {
18 std::mt19937 gen;
19 std::uniform_real_distribution<> dis;
20 fNumbers.resize(state.range(0));
21 for (std::size_t i = 0; i < fNumbers.size(); i++) {
22 fNumbers[i] = dis(gen);
23 }
24 }
25};
26
27BENCHMARK_DEFINE_F(RRegularAxis, ComputeLinearizedIndex)(benchmark::State &state)
28{
29 for (auto _ : state) {
30 for (double number : fNumbers) {
31 benchmark::DoNotOptimize(axis.ComputeLinearizedIndex(number));
32 }
33 }
34}
35BENCHMARK_REGISTER_F(RRegularAxis, ComputeLinearizedIndex)->Range(0, 32768);
36
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