[ROOT] time consuming

From: babintsev@mx.ihep.su
Date: Sun Feb 04 2001 - 11:20:57 MET


     babintsev@mx.ihep.su,  4-FEB-2001

Hello rooters.
I have a simple program below which has different time
consuming in the following 3 cases:
(ROOT Version   2.25/03 )

 1) program has lines:
    .....
       // case 1:
       one_ev[1] = i;
    .....

    [] .L toy1.C
    []  exam()
       .......
      CpuTime=6.860000 seconds

 2) program has lines:
    .....
         // case 2:
         one_ev[j*10+1] = i;
    .....

    [] .L toy1.C
    []  exam()
       .......
      CpuTime=11.290000 seconds

 3) case 2, but:
    [] .L toy1.C++
    []  exam()
       ........
      CpuTime=0.150000 seconds


 Is it a normal situation ?

....... ............ program ..............
#ifndef __CINT__

// UNIX include
#include <stdlib.h>
#include "iostream.h"

// ROOT include
#include "TROOT.h"
#include "TFile.h"
#include "TMath.h"
#include "TRandom.h"
#include "TTree.h"
#include "TBranch.h"
#include "TClonesArray.h"
#include "TStopwatch.h"
#include "TCanvas.h"
#include "TApplication.h"
#include "TBenchmark.h"
#include "TPaveLabel.h"
#include "TPaveText.h"
#include "TH1.h"
#include "TH2.h"
#include "TProfile.h"
#include "TNtuple.h"
#endif

Float_t one_ev[10000];

//----------------------//
int exam()
{
  //...   Create a timer object to benchmark this loop
   TStopwatch timer;
   timer.Start();

   Int_t nentries = 10000;
   Double_t told = 0;
   Double_t tnew = 0;
   Int_t printev = 2000;

   for (Int_t i=0; i<nentries;i++) {
       if (i%printev == 0) {
         tnew = timer.RealTime();
         printf("event:%d, rtime=%f s\n",i,tnew-told);
         told=tnew;
         timer.Continue();
       }

       for (Int_t j=0; j<1000; j++) {
         // case 1:
         //         one_ev[1] = i;

         // case 2:
         one_ev[j*10+1] = i;
       }
   }

   //...  Stop timer and print results
    timer.Stop();
    Double_t rtime = timer.RealTime();
    Double_t ctime = timer.CpuTime();
    printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);

   return 0;
}

......end of program ..............

with best wishes,  
                                   Volodja Babintsev



This archive was generated by hypermail 2b29 : Fri Jun 08 2001 - 11:51:01 MEST