Benchmark comparing row-wise and column-wise storage performance
The test consists in writing/reading to/from keys or trees To execute the benchmark:
root -
b -
q tree202_benchmarks.C or root -
b -
q tree202_benchmarks.C++
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
void billw(
const char *billname,
Int_t compress)
{
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++) {
}
printf("billw%d : RT=%7.3f s, Cpu=%7.3f s, File size= %9d bytes, CX= %g\n",
f.GetCompressionFactor());
}
void billr(
const char *billname,
Int_t compress)
{
TIter next(
f.GetListOfKeys());
auto hmean =
new TH1F(
"hmean",
"hist mean from keys", 100, 0, 1);
while ((key = (
TKey*)next())) {
hmean->Fill(
h->GetMean());
i++;
}
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)
{
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++) {
T->Fill();
}
T->Write();
delete T;
printf("billtw%d : RT=%7.3f s, Cpu=%7.3f s, File size= %9d bytes, CX= %g\n",
f.GetCompressionFactor());
}
void billtr(
const char *billtname,
Int_t compress)
{
auto hmeant =
new TH1F(
"hmeant",
"hist mean from tree", 100, 0, 1);
T->GetEntry(i);
hmeant->Fill(
h->GetMean());
}
printf(
"billtr%d : RT=%7.3f s, Cpu=%7.3f s\n", compress, timer.
RealTime(), timer.
CpuTime());
}
void tree202_benchmarks()
{
TString billt = dir +
"/billt.root";
for (
Int_t compress = 0; compress < 2; compress++) {
billw(bill, compress);
billr(bill, compress);
billtw(billt, compress);
billtr(billt, compress);
}
printf("billtot : RT=%7.3f s, Cpu=%7.3f s\n", realtime, cputime);
Float_t rootmarks = 600 * (16.98 + 14.40) / (realtime + cputime);
printf("******************************************************************\n");
printf("* ROOTMARKS =%6.1f * Root%-8s %d/%d\n", rootmarks,
printf("******************************************************************\n");
}
int Int_t
Signed integer 4 bytes (int).
double Double_t
Double 8 bytes.
long long Long64_t
Portable signed long integer 8 bytes.
float Float_t
Float 4 bytes (float).
TDirectory::TContext keeps track and restore the current directory.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
1-D histogram with a float per channel (see TH1 documentation)
Book space in a file, create I/O buffers, to fill them, (un)compress them.
virtual TObject * ReadObj()
To read a TObject* from the file.
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
void Stop()
Stop the stopwatch.
A TTree represents a columnar dataset.
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr, TClass *realClass, EDataType datatype, bool isptr, bool suppressMissingBranchError)
- Author
- Rene Brun
Definition in file tree202_benchmarks.C.