LCOV - code coverage report
Current view: top level - HLT/BASE - AliHLTComponentBenchmark.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 24 66 36.4 %
Date: 2016-06-14 17:26:59 Functions: 4 12 33.3 %

          Line data    Source code
       1             : // $Id$
       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        2142 : AliHLTComponentBenchmark::AliHLTComponentBenchmark( const char *Name )
      23         153 :   :fComponentName(Name),fNTimers(0),fNEvents(0), fTotalInput(0),fTotalOutput(0), fStatistics()
      24         102 : {
      25             :   // !
      26          51 :   Reset();
      27         102 : }
      28             : 
      29             : void AliHLTComponentBenchmark::Reset()
      30             : {
      31             :   // !
      32         114 :   fNEvents = 0;
      33          57 :   fTotalInput = 0;
      34          57 :   fTotalOutput = 0;
      35        1254 :   for( int i=0; i<10; i++ ){
      36         570 :     fTimers[i].Reset();
      37         570 :     fTotalRealTime[i] = 0;
      38         570 :     fTotalCPUTime[i] = 0;
      39             :   }
      40          57 :   fStatistics = "";
      41          57 : }
      42             : 
      43             : void AliHLTComponentBenchmark::SetName( const char *Name )
      44             : {
      45             :   // !
      46           0 :   fComponentName = Name;
      47           0 : }
      48             : 
      49             : void AliHLTComponentBenchmark::SetTimer( Int_t i, const char *Name )
      50             : {
      51             :   // !
      52          12 :   if( i>=10 ) return;
      53           6 :   if( i>=fNTimers ){
      54          18 :     for( ; fNTimers<=i; fNTimers++ ){      
      55           6 :       fTimers[fNTimers].Reset();
      56           6 :       fTotalRealTime[fNTimers] = 0;
      57           6 :       fTotalCPUTime[fNTimers] = 0;
      58           6 :       fNames[fNTimers] = Form("timer %d",fNTimers);
      59             :     }
      60           6 :     fNames[i] = Name;   
      61           6 :   }
      62           6 : }
      63             : 
      64             : void AliHLTComponentBenchmark::StartNewEvent()
      65             : {
      66             :   // !
      67           0 :   fNEvents++;
      68           0 :   for( int i=0; i<10; i++ ){
      69           0 :     fTimers[i].Reset();
      70             :   } 
      71           0 : }
      72             : 
      73             : void AliHLTComponentBenchmark::Start( Int_t i )
      74             : {
      75             :   // !
      76           0 :   if( i>=10 ) return;
      77           0 :   fTimers[i].Start();
      78           0 : }
      79             : 
      80             : void AliHLTComponentBenchmark::Stop( Int_t i )
      81             : {
      82             :   // !
      83           0 :   if( i>=10 ) return;
      84           0 :   fTimers[i].Stop();
      85           0 :   fTotalRealTime[i]+= fTimers[i].RealTime();
      86           0 :   fTotalCPUTime[i] += fTimers[i].CpuTime();
      87           0 : }
      88             : 
      89             : 
      90             : void AliHLTComponentBenchmark::AddInput( Double_t x )
      91             : {
      92             :   // !
      93           0 :   fTotalInput+=x;
      94           0 : }
      95             : 
      96             : void AliHLTComponentBenchmark::AddOutput( Double_t x )
      97             : {
      98             :   // !
      99           0 :   fTotalOutput+=x;
     100           0 : }
     101             : 
     102             : const char *AliHLTComponentBenchmark::GetStatistics()
     103             : {
     104             :   // !
     105           0 :   if( fNEvents<=0 ) return fStatistics.Data();
     106             :   float ratio = 1;
     107           0 :   if( fTotalInput >0 ) ratio = fTotalOutput / fTotalInput;
     108             : 
     109           0 :   fStatistics = Form("%s, %ld events: in %.1f Kb, out %.1f Kb, ratio %.1f", 
     110           0 :                      fComponentName.Data(), fNEvents, fTotalInput/fNEvents/1024, fTotalOutput/fNEvents/1024, ratio);
     111             :   
     112           0 :   if( fNTimers<=0 ) return fStatistics.Data();
     113           0 :   float hz = ( fTotalRealTime[0] > 0 ) ?fNEvents/fTotalRealTime[0] : 0;
     114           0 :   fStatistics+=Form("; Time %.1fms/%.1fHz (real/cpu = ",fTotalRealTime[0]/fNEvents*1.e3,hz);
     115             :   
     116           0 :   for( int i=0; i<fNTimers; i++ ){
     117           0 :     if( i>0 ) fStatistics+=", ";
     118           0 :     fStatistics+= Form("%s %.1f/%.1fms",fNames[i].Data(),fTotalRealTime[i]/fNEvents*1.e3, fTotalCPUTime[i]/fNEvents*1.e3  );    
     119             :   }
     120           0 :   fStatistics+=")";
     121           0 :   return fStatistics.Data();
     122           0 : }
     123             : 
     124             : 
     125             : void AliHLTComponentBenchmark::GetStatisticsData( Double_t* statistics, TString* names )
     126             : {
     127             :   // !
     128           0 :   if( fNEvents<=0 ) return ;
     129             : 
     130           0 :   statistics[0] = fNEvents;
     131           0 :   statistics[1] = fTotalInput/fNEvents;
     132           0 :   statistics[2] = fTotalOutput/fNEvents;
     133             :   
     134           0 :   if( fNTimers<=0 ) return ;
     135             :   
     136           0 :   for( int i=0; i<fNTimers; i++ ){
     137           0 :         names[i] = fNames[i];
     138           0 :     statistics[3+i] = fTotalRealTime[i]/fNEvents*1.e3;
     139           0 :         statistics[4+i] = fTotalCPUTime[i]/fNEvents*1.e3;    
     140             :   }
     141           0 :   return ;
     142           0 : }

Generated by: LCOV version 1.11