40 const Int_t N = 10000;
45 void billw(
const char *billname, Int_t compress) {
48 TFile f(billname,
"recreate",
"bill benchmark with keys",compress);
49 TH1F h(
"h",
"h",1000,-3,3);
50 h.FillRandom(
"gaus",50000);
52 for (Int_t i=0;i<N;i++) {
54 sprintf(name,
"h%d",i);
56 h.Fill(2*gRandom->Rndm());
60 printf(
"billw%d : RT=%7.3f s, Cpu=%7.3f s, File size= %9d bytes, CX= %g\n",compress,timer.RealTime(),timer.CpuTime(),
61 (Int_t)f.GetBytesWritten(),f.GetCompressionFactor());
64 void billr(
const char *billname, Int_t compress) {
68 TIter next(f.GetListOfKeys());
70 TH1::AddDirectory(kFALSE);
73 TH1F *hmean =
new TH1F(
"hmean",
"hist mean from keys",100,0,1);
75 while ((key=(TKey*)next())) {
76 h = (TH1F*)key->ReadObj();
77 hmean->Fill(h->GetMean());
82 printf(
"billr%d : RT=%7.3f s, Cpu=%7.3f s\n",compress,timer.RealTime(),timer.CpuTime());
85 void billtw(
const char *billtname, Int_t compress) {
88 TFile f(billtname,
"recreate",
"bill benchmark with trees",compress);
89 TH1F *h =
new TH1F(
"h",
"h",1000,-3,3);
90 h->FillRandom(
"gaus",50000);
91 TTree *T =
new TTree(
"T",
"test bill");
92 T->Branch(
"event",
"TH1F",&h,64000,0);
93 for (Int_t i=0;i<N;i++) {
95 sprintf(name,
"h%d",i);
97 h->Fill(2*gRandom->Rndm());
103 printf(
"billtw%d : RT=%7.3f s, Cpu=%7.3f s, File size= %9d bytes, CX= %g\n",compress,timer.RealTime(),timer.CpuTime(),
104 (Int_t)f.GetBytesWritten(),f.GetCompressionFactor());
107 void billtr(
const char *billtname, Int_t compress) {
112 TTree *T = (TTree*)f.Get(
"T");
113 T->SetBranchAddress(
"event",&h);
114 TH1F *hmeant =
new TH1F(
"hmeant",
"hist mean from tree",100,0,1);
115 Long64_t nentries = T->GetEntries();
116 for (Long64_t i=0;i<nentries;i++) {
118 hmeant->Fill(h->GetMean());
121 printf(
"billtr%d : RT=%7.3f s, Cpu=%7.3f s\n",compress,timer.RealTime(),timer.CpuTime());
126 TString dir = gSystem->DirName(gSystem->UnixPathName(__FILE__));
127 TString bill = dir +
"/bill.root";
128 TString billt = dir +
"/billt.root";
130 TStopwatch totaltimer;
132 for (Int_t compress=0;compress<2;compress++) {
133 billw(bill,compress);
134 billr(bill,compress);
135 billtw(billt,compress);
136 billtr(billt,compress);
138 gSystem->Unlink(bill);
139 gSystem->Unlink(billt);
141 Double_t realtime = totaltimer.RealTime();
142 Double_t cputime = totaltimer.CpuTime();
143 printf(
"billtot : RT=%7.3f s, Cpu=%7.3f s\n",realtime,cputime);
145 Float_t rootmarks = 600*(16.98 + 14.40)/(realtime + cputime);
146 printf(
"******************************************************************\n");
147 printf(
"* ROOTMARKS =%6.1f * Root%-8s %d/%d\n",rootmarks,gROOT->GetVersion(),gROOT->GetVersionDate(),gROOT->GetVersionTime());
148 printf(
"******************************************************************\n");