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