Logo ROOT  
Reference Guide
perf.cxx File Reference

Detailed Description

/*************************************************************************
* Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "ROOT/RHist.hxx"
#include "ROOT/RFit.hxx"
#include <chrono>
#include <iostream>
#include <type_traits>
using namespace ROOT;
long createNew(int count)
{
long ret = 1;
for (int i = 0; i < count; ++i) {
Experimental::RH2D hist({{{100, 0., 1.}, {{0., 1., 2., 3., 10.}}}});
ret ^= (long)&hist;
}
return ret;
}
long fillNew(int count)
{
Experimental::RH2D hist({{{100, 0., 1.}, {{0., 1., 2., 3., 10.}}}});
for (int i = 0; i < count; ++i)
hist.Fill({0.611, 0.611});
return hist.GetNDim();
}
long fillN(int count)
{
Experimental::RH2D hist({{{100, 0., 1.}, {{0., 1., 2., 3., 10.}}}});
std::vector<Experimental::Hist::RCoordArray<2>> v(count);
for (int i = 0; i < count; ++i)
v[i] = {0.611, 0.611};
hist.FillN(v);
return hist.GetNDim();
}
long fillBufferedNew(int count)
{
Experimental::RH2D hist({{{100, 0., 1.}, {{0., 1., 2., 3., 10.}}}});
for (int i = 0; i < count; ++i)
filler.Fill({0.611, 0.611});
return hist.GetNDim();
}
using timefunc_t = std::add_pointer_t<long(int)>;
void time1(timefunc_t run, int count, const std::string &name)
{
using namespace std::chrono;
auto start = high_resolution_clock::now();
run(count);
auto end = high_resolution_clock::now();
duration<double> time_span = duration_cast<duration<double>>(end - start);
std::cout << count << " * " << name << ": " << time_span.count() << "seconds \n";
}
void time(timefunc_t r7, int count, const std::string &name)
{
time1(r7, count, name + " (ROOT7)");
}
void perf()
{
time(createNew, 1000000, "create 2D hists");
time(fillNew, 100000000, "2D fills");
time(fillBufferedNew, 100000000, "2D fills (buffered)");
}
Date
2015-07-08
Warning
This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
Author
Axel Naumann axel@.nosp@m.cern.nosp@m..ch

Definition in file perf.cxx.

RHist.hxx
long
long
Definition: Converters.cxx:858
v
@ v
Definition: rootcling_impl.cxx:3635
ROOT::Experimental::RHist::Fill
void Fill(const CoordArray_t &x, Weight_t weight=(Weight_t) 1) noexcept
Add weight to the bin containing coordinate x.
Definition: RHist.hxx:151
ROOT::Experimental::RHist::GetNDim
static constexpr int GetNDim() noexcept
Number of dimensions of the coordinates.
Definition: RHist.hxx:81
ROOT::Experimental::RHist::FillN
void FillN(const std::span< const CoordArray_t > xN, const std::span< const Weight_t > weightN) noexcept
For each coordinate in xN, add weightN[i] to the bin at coordinate xN[i].
Definition: RHist.hxx:156
ROOT::Experimental::RHistBufferedFill
Definition: RHistBufferedFill.hxx:94
name
char name[80]
Definition: TGX11.cxx:110
ROOT::Experimental::RHist
Definition: RHist.hxx:44
RFit.hxx
ROOT
VSD Structures.
Definition: StringConv.hxx:21
RHistBufferedFill.hxx