Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
tree202_benchmarks.C File Reference

Detailed Description

View in nbviewer Open in SWAN
Benchmark comparing row-wise and column-wise storage performance

The test consists in writing/reading to/from keys or trees To execute the benchmark:

#define b(i)
Definition RSha256.hxx:100
float * q

for example for N=10000, the following output is produced on an 2.7 GHz Intel Core i7 (year 2011). The names featuring a "t" are relative to trees, the faster, the better.

billw0 : RT= 0.803 s, Cpu= 0.800 s, File size= 45608143 bytes, CX= 1
billr0 : RT= 0.388 s, Cpu= 0.390 s
billtw0 : RT= 0.336 s, Cpu= 0.310 s, File size= 45266881 bytes, CX= 1.00034
billtr0 : RT= 0.229 s, Cpu= 0.230 s
billw1 : RT= 1.671 s, Cpu= 1.670 s, File size= 16760526 bytes, CX= 2.72078
billr1 : RT= 0.667 s, Cpu= 0.680 s
billtw1 : RT= 0.775 s, Cpu= 0.770 s, File size= 9540884 bytes, CX= 4.74501
billtr1 : RT= 0.352 s, Cpu= 0.350 s
billtot : RT= 5.384 s, Cpu= 5.290 s
******************************************************************
* ROOTMARKS =1763.9 * Root6.05/03 20150914/948
******************************************************************
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t bytes
#include "TFile.h"
#include "TSystem.h"
#include "TH1.h"
#include "TRandom.h"
#include "TStopwatch.h"
#include "TKey.h"
#include "TTree.h"
#include "TROOT.h"
const Int_t N = 10000; //number of events to be processed
void billw(const char *billname, Int_t compress)
{
//write N histograms as keys
timer.Start();
TFile f(billname, "recreate", "bill benchmark with keys", compress);
TH1F h("h", "h", 1000, -3, 3);
h.FillRandom("gaus", 50000);
for (Int_t i = 0; i < N; i++) {
char name[20];
sprintf(name, "h%d", i);
h.SetName(name);
h.Fill( 2 * gRandom->Rndm());
h.Write();
}
timer.Stop();
printf("billw%d : RT=%7.3f s, Cpu=%7.3f s, File size= %9d bytes, CX= %g\n",
compress, timer.RealTime(), timer.CpuTime(), (Int_t)f.GetBytesWritten(),
f.GetCompressionFactor());
}
void billr(const char *billname, Int_t compress)
{
//read N histograms from keys
timer.Start();
TIter next(f.GetListOfKeys());
TH1F *h;
TKey *key;
Int_t i = 0;
auto hmean = new TH1F("hmean", "hist mean from keys", 100, 0, 1);
while ((key = (TKey*)next())) {
h = (TH1F*)key->ReadObj();
hmean->Fill(h->GetMean());
delete h;
i++;
}
timer.Stop();
printf("billr%d : RT=%7.3f s, Cpu=%7.3f s\n", compress, timer.RealTime(), timer.CpuTime());
}
void billtw(const char *billtname, Int_t compress)
{
//write N histograms to a Tree
timer.Start();
TFile f(billtname,"recreate", "bill benchmark with trees", compress);
auto h = new TH1F("h", "h", 1000, -3, 3);
h->FillRandom("gaus", 50000);
auto T = new TTree("T", "test bill");
T->Branch("event", "TH1F", &h, 64000, 0);
for (Int_t i = 0; i < N; i++) {
char name[20];
sprintf(name, "h%d", i);
h->SetName(name);
h->Fill(2 * gRandom->Rndm());
T->Fill();
}
T->Write();
delete T;
timer.Stop();
printf("billtw%d : RT=%7.3f s, Cpu=%7.3f s, File size= %9d bytes, CX= %g\n",
compress, timer.RealTime(), timer.CpuTime(), (Int_t)f.GetBytesWritten(),
f.GetCompressionFactor());
}
void billtr(const char *billtname, Int_t compress)
{
//read N histograms from a tree
timer.Start();
TH1F *h = nullptr;
auto T = f.Get<TTree>("T");
T->SetBranchAddress("event", &h);
auto hmeant = new TH1F("hmeant", "hist mean from tree", 100, 0, 1);
Long64_t nentries = T->GetEntries();
for (Long64_t i = 0; i < nentries; i++) {
T->GetEntry(i);
hmeant->Fill(h->GetMean());
}
timer.Stop();
printf("billtr%d : RT=%7.3f s, Cpu=%7.3f s\n", compress, timer.RealTime(), timer.CpuTime());
}
{
TString bill = dir + "/bill.root";
TString billt = dir + "/billt.root";
totaltimer.Start();
for (Int_t compress = 0; compress < 2; compress++) {
}
totaltimer.Stop();
printf("billtot : RT=%7.3f s, Cpu=%7.3f s\n", realtime, cputime);
//reference is a P IV 2.4 GHz
Float_t rootmarks = 600 * (16.98 + 14.40) / (realtime + cputime);
printf("******************************************************************\n");
printf("* ROOTMARKS =%6.1f * Root%-8s %d/%d\n", rootmarks,
gROOT->GetVersion(), gROOT->GetVersionDate(), gROOT->GetVersionTime());
printf("******************************************************************\n");
}
#define f(i)
Definition RSha256.hxx:104
#define h(i)
Definition RSha256.hxx:106
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:69
#define N
char name[80]
Definition TGX11.cxx:110
int nentries
#define gROOT
Definition TROOT.h:406
R__EXTERN TRandom * gRandom
Definition TRandom.h:62
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:131
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:647
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
Definition TH1.cxx:1264
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition TKey.h:28
virtual TObject * ReadObj()
To read a TObject* from the file.
Definition TKey.cxx:758
Double_t Rndm() override
Machine independent random number generator.
Definition TRandom.cxx:559
Stopwatch class.
Definition TStopwatch.h:28
Basic string class.
Definition TString.h:139
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1074
virtual TString GetDirName(const char *pathname)
Return the directory name in pathname.
Definition TSystem.cxx:1043
virtual int Unlink(const char *name)
Unlink, i.e.
Definition TSystem.cxx:1392
A TTree represents a columnar dataset.
Definition TTree.h:79
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=nullptr)
Change branch address, dealing with clone trees properly.
Definition TTree.cxx:8479
Author
Rene Brun

Definition in file tree202_benchmarks.C.