Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
hist_benchmark_engine.cxx
Go to the documentation of this file.
3
4#include <benchmark/benchmark.h>
5
6#include <random>
7#include <vector>
8
9struct RHistEngine_int_Regular1 : public benchmark::Fixture {
10 // The objects are stored and constructed in the fixture to avoid compiler optimizations in the benchmark body taking
11 // advantage of the (constant) constructor parameters.
14 std::vector<double> fNumbers;
15
16 // Avoid GCC warning
17 using benchmark::Fixture::SetUp;
18 void SetUp(benchmark::State &state) final
19 {
20 std::mt19937 gen;
21 std::uniform_real_distribution<> dis;
22 fNumbers.resize(state.range(0));
23 for (std::size_t i = 0; i < fNumbers.size(); i++) {
24 fNumbers[i] = dis(gen);
25 }
26 }
27};
28
29BENCHMARK_DEFINE_F(RHistEngine_int_Regular1, Fill)(benchmark::State &state)
30{
31 for (auto _ : state) {
32 for (double number : fNumbers) {
33 engine.Fill(number);
34 }
35 }
36}
38
39struct RHistEngine_int_Regular2 : public benchmark::Fixture {
40 // The objects are stored and constructed in the fixture to avoid compiler optimizations in the benchmark body taking
41 // advantage of the (constant) constructor parameters.
44 std::vector<double> fNumbers;
45
46 // Avoid GCC warning
47 using benchmark::Fixture::SetUp;
48 void SetUp(benchmark::State &state) final
49 {
50 std::mt19937 gen;
51 std::uniform_real_distribution<> dis;
52 fNumbers.resize(2 * state.range(0));
53 for (std::size_t i = 0; i < fNumbers.size(); i++) {
54 fNumbers[i] = dis(gen);
55 }
56 }
57};
58
59BENCHMARK_DEFINE_F(RHistEngine_int_Regular2, Fill)(benchmark::State &state)
60{
61 for (auto _ : state) {
62 for (std::size_t i = 0; i < fNumbers.size(); i += 2) {
63 engine.Fill(fNumbers[i], fNumbers[i + 1]);
64 }
65 }
66}
68
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 histogram data structure to bin data along multiple dimensions.
A regular axis with equidistant bins in the interval .
BENCHMARK_DEFINE_F(RHistEngine_int_Regular1, Fill)(benchmark
BENCHMARK_MAIN()
BENCHMARK_REGISTER_F(RHistEngine_int_Regular1, Fill) -> Range(0, 32768)
ROOT::Experimental::RHistEngine< int > engine
void SetUp(benchmark::State &state) final
ROOT::Experimental::RRegularAxis axis
ROOT::Experimental::RRegularAxis axis
ROOT::Experimental::RHistEngine< int > engine
void SetUp(benchmark::State &state) final