]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/Cal/AliTRDbenchmarkCalibDB.C
Update of calibration classes by Jan Fiete
[u/mrichter/AliRoot.git] / TRD / Cal / AliTRDbenchmarkCalibDB.C
1 #if !defined( __CINT__) || defined(__MAKECINT__)
2
3 #include <iostream>
4
5 #include "AliTRDcalibDB.h"
6 #include <TStopwatch.h>
7 #include <TRandom.h>
8
9 extern TRandom* gRandom;
10
11 #endif
12
13 #define BENCHMARK(code, comment) \
14   timer.Reset(); timer.Start(); \
15   for (Int_t i=0; i<NUMBER; ++i) { \
16   code \
17   } \
18   timer.Stop(); \
19   cerr   << "Tested " << NUMBER << " times: " << comment << ". Time/call: " << timer.CpuTime() / NUMBER << endl; \
20   timer.Print();
21
22 #define NUMBER 100000
23
24 void AliTRDbenchmarkCalibDB()
25 {
26   TStopwatch timer; 
27   AliTRDcalibDB* calib = AliTRDcalibDB::Instance();
28   if (!calib)
29   {
30     cerr << "calibDB singleton has already been terminated." << endl;
31     return;
32   }
33
34   Float_t xyz[3];
35   
36   calib->SetRun(1);
37   calib->SetRun(0);
38   calib->GetNumberOfTimeBins();
39   
40   BENCHMARK(calib->GetNumberOfTimeBins();, "GetNumberOfTimeBins");
41   BENCHMARK(calib->GetChamberPos(1, xyz);, "GetChamberPos");
42   BENCHMARK(calib->GetVdrift((Int_t) (gRandom->Uniform() * 500), (Int_t) (gRandom->Uniform() * 100), (Int_t) (gRandom->Uniform() * 10));, "GetVdrift");
43
44   #undef NUMBER
45   #define NUMBER 10000
46   BENCHMARK(calib->SetRun(1); calib->SetRun(0); calib->GetNumberOfTimeBins();, "GetNumberOfTimeBins with invalidating");
47   BENCHMARK(calib->SetRun(1); calib->SetRun(0); calib->GetChamberPos(1, xyz);, "GetChamberPos with invalidating");
48   #undef NUMBER
49   #define NUMBER 200
50   BENCHMARK(calib->SetRun(1); calib->SetRun(0); calib->GetVdrift(1, 1, 1);, "GetVdrift with invalidating");
51   
52   AliTRDcalibDB::Terminate();
53 }