]>
Commit | Line | Data |
---|---|---|
be6bf2a1 | 1 | // $Id$ |
57a4102f | 2 | // ************************************************************************** |
3 | // This file is property of and copyright by the ALICE HLT Project * | |
4 | // ALICE Experiment at CERN, All rights reserved. * | |
5 | // * | |
6 | // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> | |
7 | // for The ALICE HLT Project. * | |
8 | // * | |
9 | // Permission to use, copy, modify and distribute this software and its * | |
10 | // documentation strictly for non-commercial purposes is hereby granted * | |
11 | // without fee, provided that the above copyright notice appears in all * | |
12 | // copies and that both the copyright notice and this permission notice * | |
13 | // appear in the supporting documentation. The authors make no claims * | |
14 | // about the suitability of this software for any purpose. It is * | |
15 | // provided "as is" without express or implied warranty. * | |
16 | // * | |
17 | //*************************************************************************** | |
18 | ||
19 | ||
20 | #include "AliHLTComponentBenchmark.h" | |
21 | ||
22 | AliHLTComponentBenchmark::AliHLTComponentBenchmark( const char *Name ) | |
23 | :fComponentName(Name),fNTimers(0),fNEvents(0), fTotalInput(0),fTotalOutput(0), fStatistics() | |
24 | { | |
25 | // ! | |
26 | Reset(); | |
27 | } | |
28 | ||
29 | void AliHLTComponentBenchmark::Reset() | |
30 | { | |
31 | // ! | |
32 | fNEvents = 0; | |
33 | fTotalInput = 0; | |
34 | fTotalOutput = 0; | |
35 | for( int i=0; i<10; i++ ){ | |
36 | fTimers[i].Reset(); | |
37 | fTotalRealTime[i] = 0; | |
38 | fTotalCPUTime[i] = 0; | |
39 | } | |
40 | fStatistics = ""; | |
41 | } | |
42 | ||
43 | void AliHLTComponentBenchmark::SetName( const char *Name ) | |
44 | { | |
45 | // ! | |
46 | fComponentName = Name; | |
47 | } | |
48 | ||
49 | void AliHLTComponentBenchmark::SetTimer( Int_t i, const char *Name ) | |
50 | { | |
51 | // ! | |
52 | if( i>=10 ) return; | |
53 | if( i>=fNTimers ){ | |
54 | for( ; fNTimers<=i; fNTimers++ ){ | |
55 | fTimers[fNTimers].Reset(); | |
56 | fTotalRealTime[fNTimers] = 0; | |
57 | fTotalCPUTime[fNTimers] = 0; | |
58 | fNames[fNTimers] = Form("timer %d",fNTimers); | |
59 | } | |
60 | fNames[i] = Name; | |
61 | } | |
62 | } | |
63 | ||
64 | void AliHLTComponentBenchmark::StartNewEvent() | |
65 | { | |
66 | // ! | |
67 | fNEvents++; | |
68 | for( int i=0; i<10; i++ ){ | |
69 | fTimers[i].Reset(); | |
70 | } | |
71 | } | |
72 | ||
73 | void AliHLTComponentBenchmark::Start( Int_t i ) | |
74 | { | |
75 | // ! | |
76 | if( i>=10 ) return; | |
77 | fTimers[i].Start(); | |
78 | } | |
79 | ||
80 | void AliHLTComponentBenchmark::Stop( Int_t i ) | |
81 | { | |
82 | // ! | |
83 | if( i>=10 ) return; | |
84 | fTimers[i].Stop(); | |
85 | fTotalRealTime[i]+= fTimers[i].RealTime(); | |
86 | fTotalCPUTime[i] += fTimers[i].CpuTime(); | |
87 | } | |
88 | ||
89 | ||
90 | void AliHLTComponentBenchmark::AddInput( Double_t x ) | |
91 | { | |
92 | // ! | |
93 | fTotalInput+=x; | |
94 | } | |
95 | ||
96 | void AliHLTComponentBenchmark::AddOutput( Double_t x ) | |
97 | { | |
98 | // ! | |
99 | fTotalOutput+=x; | |
100 | } | |
101 | ||
102 | const char *AliHLTComponentBenchmark::GetStatistics() | |
103 | { | |
104 | // ! | |
105 | if( fNEvents<=0 ) return fStatistics.Data(); | |
106 | float ratio = 1; | |
107 | if( fTotalInput >0 ) ratio = fTotalOutput / fTotalInput; | |
108 | ||
be6bf2a1 | 109 | fStatistics = Form("%s, %ld events: in %.1f Kb, out %.1f Kb, ratio %.1f", |
57a4102f | 110 | fComponentName.Data(), fNEvents, fTotalInput/fNEvents/1024, fTotalOutput/fNEvents/1024, ratio); |
111 | ||
112 | if( fNTimers<=0 ) return fStatistics.Data(); | |
ac1afabc | 113 | float hz = ( fTotalRealTime[0] > 0 ) ?fNEvents/fTotalRealTime[0] : 0; |
114 | fStatistics+=Form("; Time %.1fms/%.1fHz (real/cpu = ",fTotalRealTime[0]/fNEvents*1.e3,hz); | |
57a4102f | 115 | |
116 | for( int i=0; i<fNTimers; i++ ){ | |
117 | if( i>0 ) fStatistics+=", "; | |
118 | fStatistics+= Form("%s %.1f/%.1fms",fNames[i].Data(),fTotalRealTime[i]/fNEvents*1.e3, fTotalCPUTime[i]/fNEvents*1.e3 ); | |
119 | } | |
120 | fStatistics+=")"; | |
121 | return fStatistics.Data(); | |
122 | } | |
eb70c0fb | 123 | |
124 | ||
125 | void AliHLTComponentBenchmark::GetStatisticsData( Double_t* statistics, TString* names ) | |
126 | { | |
127 | // ! | |
128 | if( fNEvents<=0 ) return ; | |
eb70c0fb | 129 | |
130 | statistics[0] = fNEvents; | |
488e1434 | 131 | statistics[1] = fTotalInput/fNEvents; |
132 | statistics[2] = fTotalOutput/fNEvents; | |
eb70c0fb | 133 | |
134 | if( fNTimers<=0 ) return ; | |
135 | ||
136 | for( int i=0; i<fNTimers; i++ ){ | |
137 | names[i] = fNames[i]; | |
f9ce172e | 138 | statistics[3+i] = fTotalRealTime[i]/fNEvents*1.e3; |
139 | statistics[4+i] = fTotalCPUTime[i]/fNEvents*1.e3; | |
eb70c0fb | 140 | } |
141 | return ; | |
142 | } |