From b9f9f6c0c8033ec875ef5e1ac4e5abb69f7c873c Mon Sep 17 00:00:00 2001 From: Rene Brun <Rene.Brun@cern.ch> Date: Mon, 26 Feb 2001 10:52:14 +0000 Subject: [PATCH] Add a new test suite and benchmark: // this test program compares the I/O performance obtained with // STL vector of objects or pointers to objects versus the native // Root collection class TClonesArray. // Trees in compression and non compression mode are created for each // of the following cases: // -vector<THit> // -vector<THit*> // -TClonesArray(TObjHit) in no split mode // -TClonesArray(TObjHit) in split mode // where: // THit is a class not derived from TObject // TObjHit derives from TObject and THit // // The test prints a summary table comparing performances for all above cases / (CPU, file size, compression factors). // Reference numbers on a Pentium III 650 Mhz machine are given as reference. This new test is also to test the portability of STL on the upported platforms. Makefile.in modified to include the new benchmark. To run the test suite, simply execute bench. git-svn-id: http://root.cern.ch/svn/root/trunk@1704 27541ba8-7e3a-0410-8455-c3a389f83636 --- test/Makefile.in | 41 ++++++- test/TBench.cxx | 288 ++++++++++++++++++++++++++++++++++++++++++++ test/TBench.h | 100 +++++++++++++++ test/bench.cxx | 262 ++++++++++++++++++++++++++++++++++++++++ test/benchLinkDef.h | 13 ++ 5 files changed, 702 insertions(+), 2 deletions(-) create mode 100644 test/TBench.cxx create mode 100644 test/TBench.h create mode 100644 test/bench.cxx create mode 100644 test/benchLinkDef.h diff --git a/test/Makefile.in b/test/Makefile.in index 64f77198191..79de2239e54 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -454,13 +454,21 @@ STRESSO = stress.$(ObjSuf) STRESSS = stress.$(SrcSuf) STRESS = stress$(ExeSuf) +TBENCHO = TBench.$(ObjSuf) TBenchDict.$(ObjSuf) +TBENCHS = TBench.$(SrcSuf) TBenchDict.$(SrcSuf) +TBENCHSO = TBench.$(DllSuf) + +BENCHO = bench.$(ObjSuf) +BENCHS = bench.$(SrcSuf) +BENCH = bench$(ExeSuf) + OBJS = $(EVENTO) $(MAINEVENTO) $(HWORLDO) $(HSIMPLEO) $(MINEXAMO) \ $(TSTRINGO) $(TCOLLEXO) $(VVECTORO) $(VMATRIXO) $(VLAZYO) \ - $(HELLOO) $(ACLOCKO) $(STRESSO) + $(HELLOO) $(ACLOCKO) $(STRESSO) $(TBENCHO) $(BENCHO) PROGRAMS = $(EVENT) $(HWORLD) $(HSIMPLE) $(MINEXAM) $(TSTRING) \ $(TCOLLEX) $(VVECTOR) $(VMATRIX) $(VLAZY) \ - $(HELLOSO) $(ACLOCKSO) $(STRESS) + $(HELLOSO) $(ACLOCKSO) $(STRESS) $(TBENCHSO) $(BENCH) ifneq ($(ARCH),win32) OBJS += $(GUITESTO) $(TETRISO) PROGRAMS += $(GUITEST) $(TETRISSO) @@ -549,6 +557,10 @@ $(STRESS): $(STRESSO) $(EVENT) $(LD) $(LDFLAGS) $(STRESSO) $(EVENTLIB) $(LIBS) $(OutPutOpt)$@ @echo "$@ done" +$(BENCH): $(BENCHO) $(TBENCH) + $(LD) $(LDFLAGS) $(BENCHO) $(TBENCHO) $(LIBS) $(OutPutOpt)$@ + @echo "$@ done" + Hello: $(HELLOSO) $(HELLOSO): $(HELLOO) ifeq ($(ARCH),aix) @@ -609,6 +621,26 @@ endif endif endif +TBench: $(TBENCHSO) +$(TBENCHSO): $(TBENCHO) +ifeq ($(ARCH),aix) + /usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $(TBENCHSO) $(GLIBS) -p 0 $(TBENCHO) +else +ifeq ($(ARCH),alphacxx) +# due to a bug in cxx/ld under osf3.xx, one cannot use cxx to generate +# a shared library. One must use ld instead. + ld -L/usr/lib/cmplrs/cxx -rpath /usr/lib/cmplrs/cxx -expect_unresolved "*" \ + -g0 -O1 -shared /usr/lib/cmplrs/cc/crt0.o /usr/lib/cmplrs/cxx/_main.o \ + -o TBench.so TBench.o TBenchDict.o -lcxxstd -lcxx -lexc -lots -lc +else +ifeq ($(ARCH),win32) + $(LD) $(SOFLAGS) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@ +else + $(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ +endif +endif +endif + clean: @rm -f $(OBJS) core @@ -642,5 +674,10 @@ TetrisDict.$(SrcSuf): Tetris.h @echo "Generating dictionary TetrisDict..." @rootcint -f TetrisDict.$(SrcSuf) -c Tetris.h +TBench.$(ObjSuf): TBench.h +TBenchDict.$(SrcSuf): TBench.h + @echo "Generating dictionary TBenchDict..." + @rootcint -f TBenchDict.$(SrcSuf) -c TBench.h benchLinkDef.h + .$(SrcSuf).$(ObjSuf): $(CXX) $(CXXFLAGS) -c $< diff --git a/test/TBench.cxx b/test/TBench.cxx new file mode 100644 index 00000000000..46f0a754bba --- /dev/null +++ b/test/TBench.cxx @@ -0,0 +1,288 @@ +// set of classes to compare the performance of STL vector versus +// native Root TClonesArray. +// See main program bench.cxx + +#include "TBench.h" +#include "TRandom.h" +#include "TFile.h" +#include "TTree.h" +#include "TClass.h" + +THit hit; +//------------------------------------------------------------- +ClassImp(THit) +//------------------------------------------------------------- +THit::THit() { + fPulses = 0; +} +THit::THit(const THit &hit) { + fX = hit.fX; + fY = hit.fY; + fZ = hit.fZ; + for (Int_t i=0;i<10;i++) fTime[i] = hit.fTime[i]; + fPulses = 0; + fNpulses = hit.fNpulses; + if (fNpulses == 0) return; + if (hit.fPulses == 0) return; + fPulses = new int[fNpulses]; + for (int j=0;j<fNpulses;j++) fPulses[j] = hit.fPulses[j]; +} + +THit::THit(int t) { + fPulses = 0; + Set(t); +} + +THit::~THit() { + if (fPulses) delete [] fPulses; + fPulses = 0; +} + +void THit::Set(int t) { + fX = gRandom->Gaus(0,1); + fY = gRandom->Gaus(0,1); + fZ = gRandom->Gaus(0,10); + fNpulses = t%20 + 1; + fPulses = new int[fNpulses]; + for (int j=0;j<fNpulses;j++) fPulses[j] = j+1; + for (int i=0; i<10; i++) fTime[i] = t+i; +} + +TBuffer &operator>>(TBuffer &buf, THit *&obj) +{ + obj = new THit(); + obj->Streamer(buf); + return buf; +} + +TBuffer &operator<<(TBuffer &buf, const THit *obj) +{ + ((THit*)obj)->Streamer(buf); + return buf; +} + +//------------------------------------------------------------- +ClassImp(TObjHit) +//------------------------------------------------------------- + +TObjHit::TObjHit() :THit() {} +TObjHit::TObjHit(int t) :THit(t) {} + +//------------------------------------------------------------- +ClassImp(TSTLhit) +//------------------------------------------------------------- +TSTLhit::TSTLhit() +{ +} + +TSTLhit::TSTLhit(Int_t nmax) +{ + fNhits = nmax; + fList1.reserve(nmax); +} + +TSTLhit::~TSTLhit() { +} + +void TSTLhit::Clear(Option_t *) +{ + fList1.erase(fList1.begin(),fList1.end()); +} + +void TSTLhit::MakeEvent(int ievent) +{ + Clear(); + for (Int_t j=0; j<fNhits; j++) { + hit.Set(j); + fList1.push_back(hit); + } +} + +Int_t TSTLhit::MakeTree(int mode, int nevents, int compression, int split, float &cx) +{ + TFile *f=0; + TTree *T=0; + TSTLhit *top = this; + if (mode > 0) { + f = new TFile("demoSTLhit.root","recreate","STLhit",compression); + T = new TTree("T","Demo tree"); + T->Bronch("event","TSTLhit",&top,64000,split); + } + for (int ievent=0; ievent<nevents; ievent++) { + MakeEvent(ievent); + if (mode > 0) T->Fill(); + } + + if (mode == 0) return 0; + T->Write(); + delete f; + f = new TFile("demoSTLhit.root"); + Int_t nbytes = f->GetEND(); + cx = f->GetCompressionFactor(); + delete f; + return nbytes; +} + +Int_t TSTLhit::ReadTree() +{ + TSTLhit *top = this; + TFile *f = new TFile("demoSTLhit.root"); + TTree *T = (TTree*)f->Get("T"); + T->SetBranchAddress("event",&top); + Int_t nevents = (Int_t)T->GetEntries(); + Int_t nbytes = 0; + for (int ievent=0; ievent<nevents; ievent++) { + nbytes += T->GetEntry(ievent); + Clear(); + } + delete f; + return nbytes; +} + + +//------------------------------------------------------------- +ClassImp(TSTLhitStar) +//------------------------------------------------------------- +TSTLhitStar::TSTLhitStar() +{ +} + +TSTLhitStar::TSTLhitStar(Int_t nmax) +{ + fNhits = nmax; + fList2.reserve(nmax); +} + +TSTLhitStar::~TSTLhitStar() { +} + +void TSTLhitStar::Clear(Option_t *) +{ + for (vector<THit*>::iterator it = fList2.begin(); it<fList2.end(); it++) { + delete (*it); + } + fList2.erase(fList2.begin(),fList2.end()); +} + +void TSTLhitStar::MakeEvent(int ievent) +{ + Clear(); + for (Int_t j=0; j<fNhits; j++) { + fList2.push_back(new THit(j)); + } +} + +Int_t TSTLhitStar::MakeTree(int mode, int nevents, int compression, int split, float &cx) +{ + TFile *f=0; + TTree *T=0; + TSTLhitStar *top = this; + if (mode > 0) { + f = new TFile("demoSTLhitStar.root","recreate","STLhitStar",compression); + T = new TTree("T","Demo tree"); + T->Bronch("event","TSTLhitStar",&top,64000,split); + } + for (int ievent=0; ievent<nevents; ievent++) { + MakeEvent(ievent); + if (mode > 0) T->Fill(); + } + + if (mode == 0) return 0; + T->Write(); + delete f; + f = new TFile("demoSTLhitStar.root"); + Int_t nbytes = f->GetEND(); + cx = f->GetCompressionFactor(); + delete f; + return nbytes; +} + +Int_t TSTLhitStar::ReadTree() +{ + TSTLhitStar *top = this; + TFile *f = new TFile("demoSTLhitStar.root"); + TTree *T = (TTree*)f->Get("T"); + T->SetBranchAddress("event",&top); + Int_t nevents = (Int_t)T->GetEntries(); + Int_t nbytes = 0; + for (int ievent=0; ievent<nevents; ievent++) { + nbytes += T->GetEntry(ievent); + Clear(); + } + delete f; + return nbytes; +} + + +//------------------------------------------------------------- +ClassImp(TCloneshit) +//------------------------------------------------------------- +TCloneshit::TCloneshit() +{ + fList3 = new TClonesArray("TObjHit"); +} + +TCloneshit::TCloneshit(Int_t nmax) +{ + fNhits = nmax; + fList3 = new TClonesArray("TObjHit",nmax); + TObjHit::Class()->IgnoreTObjectStreamer(); +} + +TCloneshit::~TCloneshit() { +} + +void TCloneshit::Clear(Option_t *) +{ + fList3->Delete(); + //fList3->Clear(); +} + +void TCloneshit::MakeEvent(int ievent) +{ + Clear(); + for (Int_t j=0; j<fNhits; j++) { + new((*fList3)[j]) TObjHit(j); + } +} + +Int_t TCloneshit::MakeTree(int mode, int nevents, int compression, int split, float &cx) +{ + TFile *f=0; + TTree *T=0; + TCloneshit *top = this; + if (mode > 0) { + f = new TFile("demoCloneshit.root","recreate","Cloneshit",compression); + T = new TTree("T","Demo tree"); + T->Bronch("event","TCloneshit",&top,64000,split); + } + for (int ievent=0; ievent<nevents; ievent++) { + MakeEvent(ievent); + if (mode > 0) T->Fill(); + } + + if (mode == 0) return 0; + T->Write(); + delete f; + f = new TFile("demoCloneshit.root"); + Int_t nbytes = f->GetEND(); + cx = f->GetCompressionFactor(); + delete f; + return nbytes; +} + +Int_t TCloneshit::ReadTree() +{ + TCloneshit *top = this; + TFile *f = new TFile("demoCloneshit.root"); + TTree *T = (TTree*)f->Get("T"); + T->SetBranchAddress("event",&top); + Int_t nevents = (Int_t)T->GetEntries(); + Int_t nbytes = 0; + for (int ievent=0; ievent<nevents; ievent++) { + nbytes += T->GetEntry(ievent); + } + delete f; + return nbytes; +} + diff --git a/test/TBench.h b/test/TBench.h new file mode 100644 index 00000000000..b8e6bb6bc73 --- /dev/null +++ b/test/TBench.h @@ -0,0 +1,100 @@ +#ifndef ROOT_TBENCH +#define ROOT_TBENCH + +#include <vector> +#include "TClonesArray.h" + +//------------------------------------------------------------- +class THit { +protected: + float fX; //x position at center + float fY; //y position at center + float fZ; //z position at center + int fNpulses; //Number of pulses + int *fPulses; //[fNpulses] + int fTime[10]; //time at the 10 layers +public: + + THit(); + THit(const THit &); + THit(int time); + virtual ~THit(); + + void Set (int time); + inline int Get(int i) { return fTime[i]; } + + friend TBuffer &operator<<(TBuffer &b, const THit *hit); + + ClassDef(THit,1) // the hit class +}; + +//------------------------------------------------------------- +class TObjHit : public TObject, public THit { + +public: + + TObjHit(); + TObjHit(int time); + virtual ~TObjHit(){;} + + ClassDef(TObjHit,1) // the hit class +}; + +//------------------------------------------------------------- +class TSTLhit { +protected: + Int_t fNhits; + vector <THit> fList1; //|| + +public: + + TSTLhit(); + TSTLhit(int nmax); + void Clear(Option_t *option=""); + virtual ~TSTLhit(); + void MakeEvent(int ievent); + Int_t MakeTree(int mode, int nevents, int compression, int split, float &cx); + Int_t ReadTree(); + + ClassDef(TSTLhit,1) // STL vector of THit +}; + +//------------------------------------------------------------- +class TSTLhitStar { +protected: + Int_t fNhits; + vector <THit*> fList2; // + +public: + + TSTLhitStar(); + TSTLhitStar(int nmax); + void Clear(Option_t *option=""); + virtual ~TSTLhitStar(); + void MakeEvent(int ievent); + Int_t MakeTree(int mode, int nevents, int compression, int split, float &cx); + Int_t ReadTree(); + + ClassDef(TSTLhitStar,1) // STL vector of pointers to THit +}; + +//------------------------------------------------------------- +class TCloneshit { +protected: + Int_t fNhits; + TClonesArray *fList3; //-> + +public: + + TCloneshit(); + TCloneshit(int nmax); + void Clear(Option_t *option=""); + virtual ~TCloneshit(); + void MakeEvent(int ievent); + Int_t MakeTree(int mode, int nevents, int compression, int split, float &cx); + Int_t ReadTree(); + + ClassDef(TCloneshit,1) // TClonesArray of TObjHit +}; + +#endif diff --git a/test/bench.cxx b/test/bench.cxx new file mode 100644 index 00000000000..d5094832936 --- /dev/null +++ b/test/bench.cxx @@ -0,0 +1,262 @@ +// this test program compares the I/O performance obtained with +// STL vector of objects or pointers to objects versus the native +// Root collection class TClonesArray. +// Trees in compression and non compression mode are created for each +// of the following cases: +// -vector<THit> +// -vector<THit*> +// -TClonesArray(TObjHit) in no split mode +// -TClonesArray(TObjHit) in split mode +// where: +// THit is a class not derived from TObject +// TObjHit derives from TObject and THit +// +// The test prints a summary table comparing performances for all above cases +// (CPU, file size, compression factors). +// Reference numbers on a Pentium III 650 Mhz machine are given as reference. + +#include "TROOT.h" +#include "TClonesArray.h" +#include "TStopwatch.h" +#include "TFile.h" +#include "TTree.h" +#include "TSystem.h" + +#include "TBench.h" + +int main(int argc, char** argv) { + TROOT root("bench","Benchmarking STL vector against TClonesArray"); + + int nhits = 1000; + int nevents = 400; + Int_t nbytes; + Float_t cx; + + //testing STL vector of THit + TStopwatch timer; + timer.Start(); + TSTLhit *STLhit = new TSTLhit(nhits); + nbytes = STLhit->MakeTree(0,nevents,0,0,cx); + timer.Stop(); + Double_t rt1 = timer.RealTime(); + Double_t cp1 = timer.CpuTime(); + printf("1 STLhit : RT=%6.2f s Cpu=%6.2f s\n",rt1,cp1); + timer.Start(kTRUE); + Int_t nbytes1 = STLhit->MakeTree(1,nevents,0,0,cx); + timer.Stop(); + Double_t rt2w = timer.RealTime(); + Double_t cp2w = timer.CpuTime(); + printf("2 STLhitw: RT=%6.2f s Cpu=%6.2f s, size= %8d bytes, cx=%5.2f\n",rt2w-rt1,cp2w-cp1,nbytes1,cx); + timer.Start(kTRUE); + nbytes = STLhit->ReadTree(); + timer.Stop(); + Double_t rt2r = timer.RealTime(); + Double_t cp2r = timer.CpuTime(); + printf("3 STLhitr: RT=%6.2f s Cpu=%6.2f s\n",rt2r,cp2r); + gSystem->Exec("rm -f demoSTLhit.root"); + timer.Start(kTRUE); + Float_t cx3; + Int_t nbytes3 = STLhit->MakeTree(1,nevents,1,0,cx3); + timer.Stop(); + Double_t rt3w = timer.RealTime(); + Double_t cp3w = timer.CpuTime(); + printf("4 STLhitw: RT=%6.2f s Cpu=%6.2f s, size= %8d bytes, cx=%5.2f\n",rt3w-rt1,cp3w-cp1,nbytes3,cx3); + timer.Start(kTRUE); + nbytes = STLhit->ReadTree(); + timer.Stop(); + Double_t rt3r = timer.RealTime(); + Double_t cp3r = timer.CpuTime(); + printf("5 STLhitr: RT=%6.2f s Cpu=%6.2f s\n",rt3r,cp3r); + gSystem->Exec("rm -f demoSTLhit.root"); + + //testing STL vector of pointers to THit + timer.Start(); + TSTLhitStar *STLhitStar = new TSTLhitStar(nhits); + nbytes = STLhitStar->MakeTree(0,nevents,0,0,cx); + timer.Stop(); + Double_t rt4 = timer.RealTime(); + Double_t cp4 = timer.CpuTime(); + printf("6 STLhit* : RT=%6.2f s Cpu=%6.2f s\n",rt4,cp4); + timer.Start(kTRUE); + Int_t nbytes5 = STLhitStar->MakeTree(1,nevents,0,1,cx); + timer.Stop(); + Double_t rt5w = timer.RealTime(); + Double_t cp5w = timer.CpuTime(); + printf("7 STLhit*w: RT=%6.2f s Cpu=%6.2f s, size= %8d bytes, cx=%5.2f\n",rt5w-rt4,cp5w-cp4,nbytes5,cx); + timer.Start(kTRUE); + nbytes = STLhitStar->ReadTree(); + timer.Stop(); + Double_t rt5r = timer.RealTime(); + Double_t cp5r = timer.CpuTime(); + printf("8 STLhit*r: RT=%6.2f s Cpu=%6.2f s\n",rt5r,cp5r); + gSystem->Exec("rm -f demoSTLhitStar.root"); + timer.Start(kTRUE); + Float_t cx6; + Int_t nbytes6 = STLhitStar->MakeTree(1,nevents,1,1,cx6); + timer.Stop(); + Double_t rt6w = timer.RealTime(); + Double_t cp6w = timer.CpuTime(); + printf("9 STLhit*w: RT=%6.2f s Cpu=%6.2f s, size= %8d bytes, cx=%5.2f\n",rt6w-rt4,cp6w-cp4,nbytes6,cx6); + timer.Start(kTRUE); + nbytes = STLhitStar->ReadTree(); + timer.Stop(); + Double_t rt6r = timer.RealTime(); + Double_t cp6r = timer.CpuTime(); + printf("10 STLhit*r: RT=%6.2f s Cpu=%6.2f s\n",rt6r,cp6r); + gSystem->Exec("rm -f demoSTLhitStar.root"); + + //testing TClonesArray of TObjHit deriving from THit + timer.Start(); + TCloneshit *Cloneshit = new TCloneshit(nhits); + nbytes = Cloneshit->MakeTree(0,nevents,0,0,cx); + timer.Stop(); + Double_t rt7 = timer.RealTime(); + Double_t cp7 = timer.CpuTime(); + printf("11 Clones1 : RT=%6.2f s Cpu=%6.2f s\n",rt7,cp7); + timer.Start(kTRUE); + Int_t nbytes8 = Cloneshit->MakeTree(1,nevents,0,1,cx); + timer.Stop(); + Double_t rt8w = timer.RealTime(); + Double_t cp8w = timer.CpuTime(); + printf("12 Clones1w: RT=%6.2f s Cpu=%6.2f s, size= %8d bytes, cx=%5.2f\n",rt8w-rt7,cp8w-cp7,nbytes8,cx); + timer.Start(kTRUE); + nbytes = Cloneshit->ReadTree(); + timer.Stop(); + Double_t rt8r = timer.RealTime(); + Double_t cp8r = timer.CpuTime(); + printf("13 Clones1r: RT=%6.2f s Cpu=%6.2f s\n",rt8r,cp8r); + gSystem->Exec("rm -f demoCloneshit.root"); + timer.Start(kTRUE); + Float_t cx9; + Int_t nbytes9 = Cloneshit->MakeTree(1,nevents,1,1,cx9); + timer.Stop(); + Double_t rt9w = timer.RealTime(); + Double_t cp9w = timer.CpuTime(); + printf("14 Clones1w: RT=%6.2f s Cpu=%6.2f s, size= %8d bytes, cx=%5.2f\n",rt9w-rt7,cp9w-cp7,nbytes9,cx9); + timer.Start(kTRUE); + nbytes = Cloneshit->ReadTree(); + timer.Stop(); + Double_t rt9r = timer.RealTime(); + Double_t cp9r = timer.CpuTime(); + printf("15 Clones1r: RT=%6.2f s Cpu=%6.2f s\n",rt9r,cp9r); + gSystem->Exec("rm -f demoCloneshit.root"); + timer.Start(kTRUE); + Int_t nbytes10 = Cloneshit->MakeTree(1,nevents,0,2,cx); + timer.Stop(); + Double_t rt10w = timer.RealTime(); + Double_t cp10w = timer.CpuTime(); + printf("16 Clones2w: RT=%6.2f s Cpu=%6.2f s, size= %8d bytes, cx=%5.2f\n",rt10w-rt7,cp10w-cp7,nbytes10,cx); + timer.Start(kTRUE); + nbytes = Cloneshit->ReadTree(); + timer.Stop(); + Double_t rt10r = timer.RealTime(); + Double_t cp10r = timer.CpuTime(); + printf("17 Clones2r: RT=%6.2f s Cpu=%6.2f s\n",rt10r,cp10r); + gSystem->Exec("rm -f demoCloneshit.root"); + timer.Start(kTRUE); + Float_t cx11; + Int_t nbytes11 = Cloneshit->MakeTree(1,nevents,1,2,cx11); + timer.Stop(); + Double_t rt11w = timer.RealTime(); + Double_t cp11w = timer.CpuTime(); + printf("18 Clones2w: RT=%6.2f s Cpu=%6.2f s, size= %8d bytes, cx=%5.2f\n",rt11w-rt7,cp11w-cp7,nbytes11,cx11); + timer.Start(kTRUE); + nbytes = Cloneshit->ReadTree(); + timer.Stop(); + Double_t rt11r = timer.RealTime(); + Double_t cp11r = timer.CpuTime(); + printf("19 Clones2r: RT=%6.2f s Cpu=%6.2f s\n",rt11r,cp11r); + gSystem->Exec("rm -f demoCloneshit.root"); + + //print all results + printf("\n"); + printf("*********************************************************\n"); + printf("* Results comparing STL vector with TClonesArray *\n"); + printf("* Root%-8s %d/%d\n",gROOT->GetVersion(),gROOT->GetVersionDate(),gROOT->GetVersionTime()); + Bool_t UNIX = strcmp(gSystem->GetName(), "Unix") == 0; + if (UNIX) { + FILE *fp = gSystem->OpenPipe("uname -a", "r"); + char line[60]; + fgets(line,60,fp); line[59] = 0; + printf("* %s\n",line); + gSystem->ClosePipe(fp); + } else { + const char *os = gSystem->Getenv("OS"); + if (!os) printf("* Windows 95\n"); + else printf("* %s %s \n",os,gSystem->Getenv("PROCESSOR_IDENTIFIER")); + } + printf("* *\n"); + printf("* Reference machine pcnotebrun.cern.ch RedHat Linux 6.1*\n"); + printf("* (Pentium III 650 Mhz 256 Mbytes RAM, IDE disk) *\n"); + printf("* (send your results to Rene.Brun@cern.ch) *\n"); + printf("*********************************************************\n"); + printf("* Time to fill the structures (seconds) Ref Machine *\n"); + printf("*********************************************************\n"); + printf("* vector<THit> %6.2f 1.91 *\n",cp1); + printf("* vector<THit*> %6.2f 1.86 *\n",cp4); + printf("* TClonesArray(TObjHit) %6.2f 1.62 *\n",cp7); + printf("*********************************************************\n"); + printf("\n"); + printf("*********************************************************\n"); + printf("* Time to write no compress (seconds) Ref Machine *\n"); + printf("*********************************************************\n"); + printf("* vector<THit> %6.2f 1.74 *\n",cp2w-cp1); + printf("* vector<THit*> %6.2f 1.80 *\n",cp5w-cp4); + printf("* TClonesArray(TObjHit) split0 %6.2f 1.60 *\n",cp8w-cp7); + printf("* TClonesArray(TObjHit) split1 %6.2f 1.51 *\n",cp10w-cp7); + printf("*********************************************************\n"); + printf("\n"); + printf("*********************************************************\n"); + printf("* Time to write compress (seconds) Ref Machine *\n"); + printf("*********************************************************\n"); + printf("* vector<THit> %6.2f 9.58 *\n",cp3w-cp1); + printf("* vector<THit*> %6.2f 9.62 *\n",cp6w-cp4); + printf("* TClonesArray(TObjHit) split0 %6.2f 7.32 *\n",cp9w-cp7); + printf("* TClonesArray(TObjHit) split1 %6.2f 6.18 *\n",cp11w-cp7); + printf("*********************************************************\n"); + printf("\n"); + printf("*********************************************************\n"); + printf("* Time to read no compress (seconds) Ref Machine *\n"); + printf("*********************************************************\n"); + printf("* vector<THit> %6.2f 2.29 *\n",cp2r); + printf("* vector<THit*> %6.2f 2.10 *\n",cp5r); + printf("* TClonesArray(TObjHit) split0 %6.2f 1.53 *\n",cp8r); + printf("* TClonesArray(TObjHit) split1 %6.2f 1.35 *\n",cp10r); + printf("*********************************************************\n"); + printf("\n"); + printf("*********************************************************\n"); + printf("* Time to read compress (seconds) Ref Machine *\n"); + printf("*********************************************************\n"); + printf("* vector<THit> %6.2f 3.67 *\n",cp3r); + printf("* vector<THit*> %6.2f 3.27 *\n",cp6r); + printf("* TClonesArray(TObjHit) split0 %6.2f 2.14 *\n",cp9r); + printf("* TClonesArray(TObjHit) split1 %6.2f 1.94 *\n",cp11r); + printf("*********************************************************\n"); + printf("\n"); + printf("*********************************************************\n"); + printf("* Size of file no compress (bytes) Ref Machine *\n"); + printf("*********************************************************\n"); + printf("* vector<THit> %8d 42053186 *\n",nbytes1); + printf("* vector<THit*> %8d 42082028 *\n",nbytes5); + printf("* TClonesArray(TObjHit) split0 %8d 39691759 *\n",nbytes8); + printf("* TClonesArray(TObjHit) split1 %8d 39782633 *\n",nbytes10); + printf("*********************************************************\n"); + printf("\n"); + printf("*********************************************************\n"); + printf("* Size of file compress (bytes) Ref Machine *\n"); + printf("*********************************************************\n"); + printf("* vector<THit> %8d 9211657 *\n",nbytes3); + printf("* vector<THit*> %8d 9215931 *\n",nbytes6); + printf("* TClonesArray(TObjHit) split0 %8d 6090891 *\n",nbytes9); + printf("* TClonesArray(TObjHit) split1 %8d 5937761 *\n",nbytes11); + printf("*********************************************************\n"); + printf("\n"); + printf("*********************************************************\n"); + printf("* Compression factor (per cent) Ref Machine *\n"); + printf("*********************************************************\n"); + printf("* vector<THit> %5.2f 4.57 *\n",cx3); + printf("* vector<THit*> %5.2f 4.57 *\n",cx6); + printf("* TClonesArray(TObjHit) split0 %5.2f 6.52 *\n",cx9); + printf("* TClonesArray(TObjHit) split1 %5.2f 6.70 *\n",cx11); + printf("*********************************************************\n"); +} diff --git a/test/benchLinkDef.h b/test/benchLinkDef.h new file mode 100644 index 00000000000..35f43303c00 --- /dev/null +++ b/test/benchLinkDef.h @@ -0,0 +1,13 @@ +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class THit!+; +#pragma link C++ class TObjHit+; +#pragma link C++ class TSTLhit+; +#pragma link C++ class TSTLhitStar+; +#pragma link C++ class TCloneshit+; + +#endif -- GitLab