2 // **************************************************************************
3 // This file is property of and copyright by the ALICE HLT Project *
4 // ALICE Experiment at CERN, All rights reserved. *
6 // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de>
7 // for The ALICE HLT Project. *
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. *
17 //***************************************************************************
20 #include "AliHLTComponentBenchmark.h"
22 AliHLTComponentBenchmark::AliHLTComponentBenchmark( const char *Name )
23 :fComponentName(Name),fNTimers(0),fNEvents(0), fTotalInput(0),fTotalOutput(0), fStatistics()
29 void AliHLTComponentBenchmark::Reset()
35 for( int i=0; i<10; i++ ){
37 fTotalRealTime[i] = 0;
43 void AliHLTComponentBenchmark::SetName( const char *Name )
46 fComponentName = Name;
49 void AliHLTComponentBenchmark::SetTimer( Int_t i, const char *Name )
54 for( ; fNTimers<=i; fNTimers++ ){
55 fTimers[fNTimers].Reset();
56 fTotalRealTime[fNTimers] = 0;
57 fTotalCPUTime[fNTimers] = 0;
58 fNames[fNTimers] = Form("timer %d",fNTimers);
64 void AliHLTComponentBenchmark::StartNewEvent()
68 for( int i=0; i<10; i++ ){
73 void AliHLTComponentBenchmark::Start( Int_t i )
80 void AliHLTComponentBenchmark::Stop( Int_t i )
85 fTotalRealTime[i]+= fTimers[i].RealTime();
86 fTotalCPUTime[i] += fTimers[i].CpuTime();
90 void AliHLTComponentBenchmark::AddInput( Double_t x )
96 void AliHLTComponentBenchmark::AddOutput( Double_t x )
102 const char *AliHLTComponentBenchmark::GetStatistics()
105 if( fNEvents<=0 ) return fStatistics.Data();
107 if( fTotalInput >0 ) ratio = fTotalOutput / fTotalInput;
109 fStatistics = Form("%s, %ld events: in %.1f Kb, out %.1f Kb, ratio %.1f",
110 fComponentName.Data(), fNEvents, fTotalInput/fNEvents/1024, fTotalOutput/fNEvents/1024, ratio);
112 if( fNTimers<=0 ) return fStatistics.Data();
113 float hz = ( fTotalRealTime[0] > 0 ) ?fNEvents/fTotalRealTime[0] : 0;
114 fStatistics+=Form("; Time %.1fms/%.1fHz (real/cpu = ",fTotalRealTime[0]/fNEvents*1.e3,hz);
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 );
121 return fStatistics.Data();
125 void AliHLTComponentBenchmark::GetStatisticsData( Double_t* statistics, TString* names )
128 if( fNEvents<=0 ) return ;
130 statistics[0] = fNEvents;
131 statistics[1] = fTotalInput/fNEvents;
132 statistics[2] = fTotalOutput/fNEvents;
134 if( fNTimers<=0 ) return ;
136 for( int i=0; i<fNTimers; i++ ){
137 names[i] = fNames[i];
138 statistics[3+i] = fTotalRealTime[i]/fNEvents*1.e3;
139 statistics[4+i] = fTotalCPUTime[i]/fNEvents*1.e3;