51#define STATCLASSES Experimental::RHistStatContent, Experimental::RHistStatUncertainty
55 using TimePoint_t =
decltype(std::chrono::high_resolution_clock::now());
61 Timer(
const char *title,
size_t count)
67 using namespace std::chrono;
68 auto end = high_resolution_clock::now();
69 duration<double> time_span = duration_cast<duration<double>>(end -
fStart);
73 std::cout <<
fCount <<
" * " <<
fTitle <<
": " << time_span.count() <<
" seconds, \t";
74 std::cout <<
fCount / (1e6) / time_span.count() <<
" millions per seconds \n";
88 if (maxValue < minValue)
89 swap(minValue, maxValue);
90 double range = maxValue - minValue;
92 double x[
fNBinsX] = {0., 0.1, 0.3, 1.};
93 double y[
fNBinsY] = {0., 0.1, 0.2, 0.3, 1.};
95 for (
size_t i = 0; i <
fNBinsX; ++i)
96 fXBins[i] = minValue + range *
x[i];
97 for (
size_t i = 0; i <
fNBinsY; ++i)
98 fYBins[i] = minValue + range *
y[i];
110 Timer t(
"GenerateInput", numbers.size());
111 if (minVal > maxVal) {
112 std::swap(minVal, maxVal);
114 T range = maxVal - minVal;
116 size_t len = numbers.size();
117 for (
auto c = numbers.begin();
c != numbers.end(); ++
c) {
118 *
c = minVal + range *
r.Rndm();
123MakeTitle(std::string_view version, std::string_view histname, std::string_view title, std::string_view axis)
126 std::string(version) +
" " + std::string(histname) +
" " + std::string(title) +
" [" + std::string(axis) +
"]";
130template <
int dim,
typename type>
158template <
typename T,
unsigned short kNDim>
164 constexpr static unsigned short kNDim = 2;
170 static constexpr const char *
const gType =
"regular bin size ";
172 template <FillFunc_t filler>
173 static long Execute(std::vector<double> &input,
double minVal,
double maxVal)
176 ExpTH2 hist({100, minVal, maxVal}, {5, minVal, maxVal});
177 return filler(hist, input,
gType);
182 static constexpr const char *
const gType =
"irregular bin size";
184 template <FillFunc_t filler>
185 static long Execute(std::vector<double> &input,
double minVal,
double maxVal)
190 return filler(hist, input,
gType);
198 array_t *values = (array_t *)(&input[0]);
199 constexpr size_t stride =
gStride;
203 Timer t(title.c_str(), input.size() / 2);
204 for (
size_t i = 0; i < (input.size() - (stride * 2 - 1)); i += (stride * 2), values += 32) {
205 std::span<array_t> coords(values, 32);
209 return hist.GetNDim();
217 Timer t(title.c_str(), input.size() / 2);
218 for (
size_t i = 0; i < input.size() - 1; i += 2)
219 filler.
Fill({input[i], input[i + 1]});
221 return hist.GetNDim();
224 inline static long fill(
ExpTH2 &hist, std::vector<double> &input, std::string_view
gType)
228 Timer t(title.c_str(), input.size() / 2);
229 for (
size_t i = 0; i < input.size() - 1; i += 2)
230 hist.Fill({input[i], input[i + 1]});
232 return hist.GetNDim();
239 constexpr static unsigned short kNDim = 1;
245 static constexpr const char *
const gType =
"regular bin size ";
247 template <FillFunc_t filler>
248 static long Execute(std::vector<double> &input,
double minVal,
double maxVal)
251 for (
unsigned short i = 0; i <
gRepeat; ++i) {
252 ExpTH1 hist({100, minVal, maxVal});
253 result += filler(hist, input,
gType);
260 static constexpr const char *
const gType =
"irregular bin size";
262 template <FillFunc_t filler>
263 static long Execute(std::vector<double> &input,
double minVal,
double maxVal)
268 for (
unsigned short i = 0; i <
gRepeat; ++i) {
270 result += filler(hist, input,
gType);
280 array_t *values = (array_t *)(&input[0]);
281 constexpr size_t stride =
gStride;
285 Timer t(title.c_str(), input.size());
286 for (
size_t i = 0; i < (input.size() - (stride - 1)); i += (stride), values += 32) {
287 std::span<array_t> coords(values, 32);
291 return hist.GetNDim();
299 Timer t(title.c_str(), input.size());
300 for (
size_t i = 0; i < input.size(); ++i)
301 filler.
Fill({input[i]});
303 return hist.GetNDim();
306 inline static long fill(
ExpTH1 &hist, std::vector<double> &input, std::string_view
gType)
310 Timer t(title.c_str(), input.size());
311 for (
size_t i = 0; i < input.size(); ++i)
312 hist.Fill({input[i]});
314 return hist.GetNDim();
323template <
int ndim,
typename T>
342template <
typename T,
int kNDim>
348 constexpr static unsigned short kNDim = 2;
355 static constexpr const char *
const gType =
"regular bin size ";
357 template <FillFunc_t filler>
358 static long Execute(std::vector<double> &input,
double minVal,
double maxVal)
362 for (
unsigned short i = 0; i <
gRepeat; ++i) {
363 HistType_t hist(
"a",
"a hist", 100, minVal, maxVal, 5, minVal, maxVal);
364 result += filler(hist, input,
gType);
372 static constexpr const char *
const gType =
"irregular bin size";
374 template <FillFunc_t filler>
375 static long Execute(std::vector<double> &input,
double minVal,
double maxVal)
379 for (
unsigned short i = 0; i <
gRepeat; ++i) {
381 result += filler(hist, input,
gType);
393 Timer t(title.c_str(), input.size() / 2);
394 for (
size_t i = 0; i < input.size() - 1; i += 2)
395 hist.Fill(input[i], input[i + 1]);
397 return (
long)hist.GetEntries();
403 constexpr size_t stride =
gStride;
406 Timer t(title.c_str(), input.size() / 2);
407 for (
size_t i = 0; i < (input.size() - (stride * 2 - 1)); i += (stride * 2))
410 return (
long)hist.GetEntries();
418 Timer t(title.c_str(), input.size() / 2);
419 for (
size_t i = 0; i < input.size() - 1; i += 2)
420 hist.Fill(input[i], input[i + 1]);
422 return (
long)hist.GetEntries();
429 constexpr static unsigned short kNDim = 1;
436 static constexpr const char *
const gType =
"regular bin size ";
438 template <FillFunc_t filler>
439 static long Execute(std::vector<double> &input,
double minVal,
double maxVal)
443 for (
unsigned short i = 0; i <
gRepeat; ++i) {
444 HistType_t hist(
"a",
"a hist", 100, minVal, maxVal);
445 result += filler(hist, input,
gType);
453 static constexpr const char *
const gType =
"irregular bin size";
455 template <FillFunc_t filler>
456 static long Execute(std::vector<double> &input,
double minVal,
double maxVal)
460 for (
unsigned short i = 0; i <
gRepeat; ++i) {
462 result += filler(hist, input,
gType);
474 Timer t(title.c_str(), input.size());
475 for (
size_t i = 0; i < input.size() - 1; ++i)
478 return (
long)hist.GetEntries();
484 constexpr size_t stride =
gStride;
487 Timer t(title.c_str(), input.size());
488 for (
size_t i = 0; i < (input.size() - (stride - 1)); i += (stride))
489 hist.FillN(
gStride, &(input[i]),
nullptr);
491 return (
long)hist.GetEntries();
499 Timer t(title.c_str(), input.size());
500 for (
size_t i = 0; i < input.size(); ++i)
503 return (
long)hist.GetEntries();
508template <
typename T,
unsigned short kNDim>
514 using DataType_t =
double;
515 static constexpr unsigned short kNDim = 2;
519 std::vector<double> input;
522 double minVal = -5.0;
523 double maxVal = +5.0;
574 using DataType_t = float;
575 constexpr unsigned short kNDim = 2;
579 std::vector<double> input;
582 double minVal = -5.0;
583 double maxVal = +5.0;
630 using DataType_t =
double;
631 static constexpr unsigned short kNDim = 1;
635 std::vector<double> input;
638 double minVal = -5.0;
639 double maxVal = +5.0;
686 using DataType_t = float;
687 static constexpr unsigned short kNDim = 1;
691 std::vector<double> input;
694 double minVal = -5.0;
695 double maxVal = +5.0;
755 int what = 1 | 2 | 4 | 8;
757 iter = atof(argv[1]);
759 what = atoi(argv[2]);
void Fill(const CoordArray_t &x, Weight_t weight=1.)
Objects used to configure the different axis types.
Histogram class for histograms with DIMENSIONS dimensions, where each bin count is stored by a value ...
1-D histogram with a double per channel (see TH1 documentation)}
1-D histogram with a float per channel (see TH1 documentation)}
static Int_t GetDefaultBufferSize()
Static function return the default buffer size for automatic histograms the parameter fgBufferSize ma...
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
2-D histogram with a double per channel (see TH1 documentation)}
2-D histogram with a float per channel (see TH1 documentation)}
Random number generator class based on M.
const char * GetHist< 1, double >()
void speedtest(size_t count=(size_t)(1e6))
const char * GetHist< 2, double >()
void speedtest< double, 1 >(size_t count)
constexpr unsigned short gRepeat
void speedtest< float, 1 >(size_t count)
const char * GetHist< 2, float >()
const char * GetHist< 1, float >()
void histspeedtest(size_t iter=1e6, int what=255)
void GenerateInput(std::vector< T > &numbers, double minVal, double maxVal, UInt_t seed)
std::string MakeTitle(std::string_view version, std::string_view histname, std::string_view title, std::string_view axis)
void speedtest< double, 2 >(size_t count)
void speedtest< float, 2 >(size_t count)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
static constexpr size_t fNBinsY
Experimental::RAxisConfig AConf_t
BinEdges(double minValue, double maxValue)
static constexpr size_t fNBinsX
AConf_t GetConfigY() const
AConf_t GetConfigX() const
static long Execute(std::vector< double > &input, double minVal, double maxVal)
static long Execute(std::vector< double > &input, double minVal, double maxVal)
static long fill(HistType_t &hist, std::vector< double > &input, std::string_view gType)
typename Redirect< kNDim, T >::HistType_t HistType_t
static long fillN(HistType_t &hist, std::vector< double > &input, std::string_view gType)
std::add_pointer_t< long(HistType_t &hist, std::vector< double > &input, std::string_view type)> FillFunc_t
static long fillBuffered(HistType_t &hist, std::vector< double > &input, std::string_view gType)
static long Execute(std::vector< double > &input, double minVal, double maxVal)
static long Execute(std::vector< double > &input, double minVal, double maxVal)
std::add_pointer_t< long(HistType_t &hist, std::vector< double > &input, std::string_view type)> FillFunc_t
static long fillBuffered(HistType_t &hist, std::vector< double > &input, std::string_view gType)
typename Redirect< kNDim, T >::HistType_t HistType_t
static long fillN(HistType_t &hist, std::vector< double > &input, std::string_view gType)
static long fill(HistType_t &hist, std::vector< double > &input, std::string_view gType)
static long Execute(std::vector< double > &input, double minVal, double maxVal)
static long Execute(std::vector< double > &input, double minVal, double maxVal)
static long fillN(ExpTH1 &hist, std::vector< double > &input, std::string_view gType)
Experimental::RHist< kNDim, T, STATCLASSES > ExpTH1
static long fillBuffered(ExpTH1 &hist, std::vector< double > &input, std::string_view gType)
static long fill(ExpTH1 &hist, std::vector< double > &input, std::string_view gType)
std::add_pointer_t< long(ExpTH1 &hist, std::vector< double > &input, std::string_view type)> FillFunc_t
static long Execute(std::vector< double > &input, double minVal, double maxVal)
static long Execute(std::vector< double > &input, double minVal, double maxVal)
std::add_pointer_t< long(ExpTH2 &hist, std::vector< double > &input, std::string_view type)> FillFunc_t
static long fillBuffered(ExpTH2 &hist, std::vector< double > &input, std::string_view gType)
Experimental::RHist< kNDim, T, STATCLASSES > ExpTH2
static long fillN(ExpTH2 &hist, std::vector< double > &input, std::string_view gType)
static long fill(ExpTH2 &hist, std::vector< double > &input, std::string_view gType)
Timer(const char *title, size_t count)
decltype(std::chrono::high_resolution_clock::now()) TimePoint_t