]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New code to record the timing information of various methods in simulation and recons...
authorcvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 29 Jun 2007 12:29:35 +0000 (12:29 +0000)
committercvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 29 Jun 2007 12:29:35 +0000 (12:29 +0000)
STEER/AliCodeTimer.cxx [new file with mode: 0644]
STEER/AliCodeTimer.h [new file with mode: 0644]
STEER/AliReconstruction.cxx
STEER/AliSimulation.cxx
STEER/STEERLinkDef.h
STEER/libSTEER.pkg

diff --git a/STEER/AliCodeTimer.cxx b/STEER/AliCodeTimer.cxx
new file mode 100644 (file)
index 0000000..812779c
--- /dev/null
@@ -0,0 +1,339 @@
+/**************************************************************************
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
+
+// $Id$
+
+///
+/// Class to get organized with the way we're timing our methods...
+///
+/// Typical usage is based on macros (like for AliLog related ones AliDebug...)
+///
+/// The idea is to instrument the code with a few macro calls, and then,
+/// at the end of the execution, get a printout of *all* the timers, by using
+/// AliCodeTimer::Instance()->Print()
+/// instead of getting scattered outputs all over the place.
+///
+/// To time a given method, use :
+///
+/// void ClassA::MethodA(....)
+/// {
+///    AliCodeTimerAuto("")
+/// }
+///
+/// To get several timers within a same method, use : 
+///
+/// void ClassA::MethodB(...)
+/// {
+///   AliCodeTimerStart("doing something")
+///   ....
+///   AliCodeTimerStop("doing something")
+///
+///   AliCodeTimerStart("doing something else")
+///   ....
+///   AliCodeTimerStop("doing something else")
+/// }
+///
+///
+
+#include "AliCodeTimer.h"
+
+#include <TMap.h>
+#include <TObjString.h>
+#include <TStopwatch.h>
+#include <Riostream.h>
+
+/// \cond CLASSIMP
+ClassImp(AliCodeTimer)
+ClassImp(AliCodeTimer::AliPair)
+/// \endcond
+
+AliCodeTimer* AliCodeTimer::fgInstance(0x0);
+
+//_____________________________________________________________________________
+void
+AliCodeTimer::AliPair::Print(Option_t* opt) const
+{
+  // Print timer information
+  cout << opt << Form("%s R:%.4fs C:%.4fs (%d slices)",
+                      Name().Data(),Timer()->RealTime(),
+                      Timer()->CpuTime(),Timer()->Counter()-1) << endl;
+}
+
+
+//_____________________________________________________________________________
+AliCodeTimer::AliCodeTimer() : TObject(), fTimers(new TMap)
+{
+  /// Ctor
+  fTimers->SetOwner(kTRUE);
+}
+
+//_____________________________________________________________________________
+AliCodeTimer::~AliCodeTimer()
+{
+  /// Dtor
+  Reset();
+  delete fTimers;
+}
+
+//_____________________________________________________________________________
+AliCodeTimer*
+AliCodeTimer::Instance()
+{
+  // single instance of this class
+  if (!fgInstance) fgInstance = new AliCodeTimer;
+  return fgInstance;
+}
+
+//_____________________________________________________________________________
+void AliCodeTimer::Continue(const char* classname, const char* methodname, 
+                            const char* message)
+{
+  /// Resume a previously stop timer
+  TStopwatch* t = Stopwatch(classname,methodname,message);
+  if (t)
+  {
+    t->Continue();
+  }
+  else
+  {
+    AliError(Form("No timer for %s/%s/%s",classname,methodname,message));
+  }
+}
+
+//_____________________________________________________________________________
+Double_t AliCodeTimer::CpuTime(const char* classname, 
+                               const char* methodname,
+                               const char* message) const
+{
+  /// Return cpu time for a given timer
+  TStopwatch* t = Stopwatch(classname,methodname,message);
+  if (t)
+  {
+    return t->CpuTime();
+  }
+  else
+  {
+    return 0;
+  }
+}
+
+//_____________________________________________________________________________
+TMap*
+AliCodeTimer::MethodMap(const char* classname) const
+{
+  /// Return the map for a given "classname"
+  return static_cast<TMap*>(fTimers->GetValue(classname));
+}
+
+//_____________________________________________________________________________
+TObjArray*
+AliCodeTimer::MessageArray(const char* classname, const char* methodname) const
+{
+  /// Return the array for a given AliPair (classname,methodname)
+  TMap* m = MethodMap(classname);
+  if ( m ) 
+  {
+    return static_cast<TObjArray*>(m->GetValue(methodname));
+  }
+  return 0;
+}
+
+//_____________________________________________________________________________
+void AliCodeTimer::PrintMethod(const char* classname, const char* methodname) const
+{
+  /// Print all the timers for a given method
+  TObjArray* messages = MessageArray(classname,methodname);
+  messages->Sort();
+  
+  cout << "   " << methodname << " ";
+  
+  if ( messages->GetLast() == 0 ) 
+  {
+    AliPair* p = static_cast<AliPair*>(messages->First());
+    p->Print();
+  }
+  else
+  {
+    cout << endl;
+    
+    TIter next(messages);
+    AliPair* p;
+  
+    while ( ( p = static_cast<AliPair*>(next()) ) ) 
+    {
+      p->Print("        ");
+    }   
+  }
+}
+
+//_____________________________________________________________________________
+void AliCodeTimer::PrintClass(const char* classname) const
+{
+  /// Print all the timers for a given class
+  TMap* methods = MethodMap(classname);
+  TIter next(methods);
+  TObjString* methodname;
+  TObjArray methodNameArray;
+  
+  while ( ( methodname = static_cast<TObjString*>(next()) ) ) 
+  {
+    methodNameArray.Add(methodname);
+  }
+  
+  cout << classname << endl;
+  
+  methodNameArray.Sort();
+  
+  TIter mnext(&methodNameArray);
+  
+  while ( ( methodname = static_cast<TObjString*>(mnext()) ) ) 
+  {
+    PrintMethod(classname,methodname->String().Data());
+  }
+}
+  
+//_____________________________________________________________________________
+void AliCodeTimer::Print(Option_t* /*opt*/) const
+{
+  /// Print all the timers we hold
+  TIter next(fTimers);
+  TObjString* classname;
+  TObjArray classNameArray;
+  
+  while ( ( classname = static_cast<TObjString*>(next()) ) )
+  {
+    classNameArray.Add(classname);
+  }
+  
+  classNameArray.Sort();
+  
+  TIter cnext(&classNameArray);
+  while ( ( classname = static_cast<TObjString*>(cnext()) ) )
+  {
+    PrintClass(classname->String().Data());
+  }
+}
+
+//_____________________________________________________________________________
+Double_t 
+AliCodeTimer::RealTime(const char* classname, const char* methodname,
+                       const char* message) const
+{
+  /// Return real time of a given time
+  TStopwatch* t = Stopwatch(classname,methodname,message);
+  if (t)
+  {
+    return t->RealTime();
+  }
+  else
+  {
+    return 0;
+  }
+}
+
+//_____________________________________________________________________________
+void
+AliCodeTimer::Reset()
+{
+  /// Reset
+  TIter next(fTimers);
+  TObjString* classname;
+  
+  while ( ( classname = static_cast<TObjString*>(next()) ) ) 
+  {
+    TMap* m = static_cast<TMap*>(fTimers->GetValue(classname->String().Data()));
+    m->DeleteAll();
+  }
+  
+  fTimers->DeleteAll();
+}
+
+//_____________________________________________________________________________
+void 
+AliCodeTimer::Start(const char* classname, const char* methodname,
+                    const char* message)
+{
+  /// Start a given time
+  TStopwatch* t = Stopwatch(classname,methodname,message);
+  if (!t)
+  {
+    TMap* m = MethodMap(classname);
+    if (!m)
+    {
+      m = new TMap;
+      m->SetOwner(kTRUE);
+      fTimers->Add(new TObjString(classname),m);
+    }      
+    TObjArray* messages = MessageArray(classname,methodname);
+    if (!messages)
+    {
+      messages = new TObjArray;
+      messages->SetOwner(kTRUE);
+      m->Add(new TObjString(methodname),messages);
+    }
+    t = new TStopwatch;
+    t->Start(kTRUE);
+    t->Stop();
+    messages->Add(new AliPair(new TObjString(message),t));
+  }
+  t->Start(kFALSE);
+}
+
+//_____________________________________________________________________________
+void 
+AliCodeTimer::Stop(const char* classname, const char* methodname,
+                   const char* message)
+{
+  /// Stop a given timer
+  TStopwatch* t = Stopwatch(classname,methodname,message);
+  if (!t)
+  {
+    AliError(Form("No timer for %s/%s/%s",classname,methodname,message));
+  }
+  else
+  {
+    t->Stop();
+  }
+}
+
+//_____________________________________________________________________________
+TStopwatch* 
+AliCodeTimer::Stopwatch(const char* classname, const char* methodname,
+                        const char* message) const
+{
+  /// Return the internal TStopwatch for a given timer
+  TObjArray* a = MessageArray(classname,methodname);
+  if ( a ) 
+  {
+    if (message)
+    {
+      TIter next(a);
+      AliPair* p;
+      while ( ( p = static_cast<AliPair*>(next()) ) ) 
+      {
+        TString s = p->Name();
+        if ( s == TString(message) ) 
+        {
+          return p->Timer();
+        }
+      }
+    }
+    else
+    {
+      return static_cast<TStopwatch*>(a->First());
+    }
+  }
+  return 0x0;
+}
diff --git a/STEER/AliCodeTimer.h b/STEER/AliCodeTimer.h
new file mode 100644 (file)
index 0000000..8b21210
--- /dev/null
@@ -0,0 +1,159 @@
+#ifndef ALICODETIMER_H
+#define ALICODETIMER_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+* See cxx source for full Copyright notice                               */
+
+// $Id$
+
+///
+/// A class to organize TStopwatch timers used to time our code
+/// 
+// Author Laurent Aphecetche
+
+#ifndef ROOT_TString
+#  include "TString.h"
+#endif
+#ifndef ROOT_TObjString
+#  include "TObjString.h"
+#endif
+#ifndef ALILOG_H
+#  include "AliLog.h"
+#endif
+
+class TStopwatch;
+class TMap;
+
+class AliCodeTimer : public TObject
+{
+public:
+  
+  AliCodeTimer();
+  virtual ~AliCodeTimer();
+
+  /// Unique instance of this class, which is a singleton
+  static AliCodeTimer* Instance();
+  
+  /// Continue timer(classname,methodname,message)
+  void Continue(const char* classname, const char* methodname, const char* message="");
+
+  /// Return the cpu time spent in timer(classname,methodname,message)
+  Double_t CpuTime(const char* classname, const char* methodname, const char* message="") const;
+  
+  /// Print the list of timers we manage
+  void Print(Option_t* opt="") const;
+  
+  /// Return the real time spent in timer(classname,methodname,message)
+  Double_t RealTime(const char* classname, const char* methodname, const char* message="") const;
+  
+  /// Reset all our timers
+  void Reset();
+  
+  /// Start timer(classname,methodname,message)
+  void Start(const char* classname, const char* methodname, const char* message="");
+
+  /// Stop timer(classname,methodname,message)
+  void Stop(const char* classname, const char* methodname, const char* message="");
+    
+public:
+  
+  class AliPair : public TObject
+  {
+  public:
+    AliPair() : TObject(),fName(0), fTimer(0) {}
+    // ctor
+    AliPair(TObjString* name, TStopwatch* timer) : TObject(), fName(name), fTimer(timer) {}
+    virtual ~AliPair() { delete fName; }
+    
+    /// get name
+    TString Name() const { return fName->String(); }
+    /// get timer
+    TStopwatch* Timer() const { return fTimer; }
+    
+    /// we are sortable (by name)
+    virtual Bool_t IsSortable() const { return kTRUE; }
+    /// compare the names
+    virtual Int_t Compare(const TObject* object) const
+    { return fName->Compare(((const AliPair*)(object))->fName); }
+
+    virtual void Print(Option_t* opt="") const;
+
+private:
+    AliPair(const AliPair&);
+    AliPair& operator=(const AliPair&);
+    
+    TObjString* fName; // name of the timer
+    TStopwatch* fTimer; // actual timer
+    
+    ClassDef(AliPair,1) // internal class to hold (string,TStopwatch*) AliPair
+  };
+    
+  class AliAutoPtr
+  {
+    public:
+      
+    /// ctor
+      AliAutoPtr(const char* classname, const char* methodname, const char* message="") 
+      : fA(classname), fB(methodname), fC(message)
+      { AliCodeTimer::Instance()->Start(classname,methodname,message); } 
+
+    /// dtor
+      ~AliAutoPtr() { AliCodeTimer::Instance()->Stop(fA.Data(),fB.Data(),fC.Data()); }
+    
+    private:
+      TString fA; // first id
+      TString fB; // second id
+      TString fC; // third id
+  };
+  
+private:  
+  
+  TMap* MethodMap(const char* classname) const;
+  TObjArray* MessageArray(const char* classname, const char* methodname) const;
+  TStopwatch* Stopwatch(const char* classname, const char* methodname, const char* message="") const;
+  void PrintClass(const char* classname) const;
+  void PrintMethod(const char* classname, const char* methodname) const;
+  
+private:
+
+  AliCodeTimer(const AliCodeTimer& rhs);
+  AliCodeTimer& operator=(const AliCodeTimer& rhs);
+  
+  static AliCodeTimer* fgInstance; //< unique instance
+  
+  TMap* fTimers; //< internal timers
+  
+  ClassDef(AliCodeTimer,1) // A timer holder
+};
+
+#ifndef LOG_NO_DEBUG
+
+#define AliCodeTimerStartClass(message) AliCodeTimer::Instance()->Start(Class()->GetName(),FUNCTIONNAME(),message);
+#define AliCodeTimerStopClass(message) AliCodeTimer::Instance()->Stop(Class()->GetName(),FUNCTIONNAME(),message);
+#define AliCodeTimerAutoClass(message) AliCodeTimer::AliAutoPtr AliCodeTimerAliAutoPtrVariable(Class()->GetName(),FUNCTIONNAME(),message);
+
+#define AliCodeTimerStart(message) AliCodeTimer::Instance()->Start(ClassName(),FUNCTIONNAME(),message);
+#define AliCodeTimerStop(message) AliCodeTimer::Instance()->Stop(ClassName(),FUNCTIONNAME(),message);
+#define AliCodeTimerAuto(message) AliCodeTimer::AliAutoPtr AliCodeTimerAliAutoPtrVariable(ClassName(),FUNCTIONNAME(),message);
+
+#define AliCodeTimerStartGeneral(message) AliCodeTimer::Instance()->Start("General",FUNCTIONNAME(),message);
+#define AliCodeTimerStopGeneral(message) AliCodeTimer::Instance()->Stop("General",FUNCTIONNAME(),message);
+#define AliCodeTimerAutoGeneral(message) AliCodeTimer::AliAutoPtr AliCodeTimerAliAutoPtrVariable("General",FUNCTIONNAME(),message);
+
+#else
+
+#define AliCodeTimerStartClass(message)
+#define AliCodeTimerStopClass(message) 
+#define AliCodeTimerAutoClass(message) 
+
+#define AliCodeTimerStart(message) 
+#define AliCodeTimerStop(message) 
+#define AliCodeTimerAuto(message) 
+
+#define AliCodeTimerStartGeneral(message) 
+#define AliCodeTimerStopGeneral(message) 
+#define AliCodeTimerAutoGeneral(message) 
+
+#endif
+
+#endif
index cd33f80b43b7c55feab8777a753fe6b5a624efcf..2c976cab7692ebfbac3c300a4842805f5c8ab80a 100644 (file)
 #include <TSystem.h>
 #include <TROOT.h>
 #include <TPluginManager.h>
-#include <TStopwatch.h>
 #include <TGeoManager.h>
 #include <TLorentzVector.h>
 
 #include "AliReconstruction.h"
+#include "AliCodeTimer.h"
 #include "AliReconstructor.h"
 #include "AliLog.h"
 #include "AliRunLoader.h"
@@ -295,6 +295,8 @@ AliReconstruction::~AliReconstruction()
   CleanUp();
   fOptions.Delete();
   fSpecCDBUri.Delete();
+
+  AliCodeTimer::Instance()->Print();
 }
 
 //_____________________________________________________________________________
@@ -494,6 +496,8 @@ Bool_t AliReconstruction::Run(const char* input)
 {
 // run the reconstruction
 
+  AliCodeTimerAuto("")
+  
   // set the input
   if (!input) input = fInput.Data();
   TString fileName(input);
@@ -554,10 +558,6 @@ Bool_t AliReconstruction::Run(const char* input)
     }      
   }
 
-
-  TStopwatch stopwatch;
-  stopwatch.Start();
-
   // get the possibly already existing ESD file and tree
   AliESD* esd = new AliESD(); AliESD* hltesd = new AliESD();
   TFile* fileOld = NULL;
@@ -795,9 +795,6 @@ Bool_t AliReconstruction::Run(const char* input)
   }
 
 
-  AliInfo(Form("Execution time for filling ESD : R:%.2fs C:%.2fs",
-              stopwatch.RealTime(),stopwatch.CpuTime()));
-
   file->cd();
   if (fWriteESDfriend)
     tree->SetBranchStatus("ESDfriend*",0);
@@ -826,8 +823,7 @@ Bool_t AliReconstruction::RunLocalReconstruction(const TString& detectors)
 {
 // run the local reconstruction
 
-  TStopwatch stopwatch;
-  stopwatch.Start();
+  AliCodeTimerAuto("")
 
   AliCDBManager* man = AliCDBManager::Instance();
   Bool_t origCache = man->GetCacheFlag();
@@ -839,25 +835,26 @@ Bool_t AliReconstruction::RunLocalReconstruction(const TString& detectors)
     if (!reconstructor) continue;
     if (reconstructor->HasLocalReconstruction()) continue;
 
+    AliCodeTimerStart(Form("running reconstruction for %s", fgkDetectorName[iDet]));
     AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet]));
-    TStopwatch stopwatchDet;
-    stopwatchDet.Start();
-
+    
+    AliCodeTimerStart(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet]));                          
     AliInfo(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet]));
 
     man->SetCacheFlag(kTRUE);
     TString calibPath = Form("%s/Calib/*", fgkDetectorName[iDet]);
     man->GetAll(calibPath); // entries are cached!
 
+    AliCodeTimerStop(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet]));
+     
     if (fRawReader) {
       fRawReader->RewindEvents();
       reconstructor->Reconstruct(fRunLoader, fRawReader);
     } else {
       reconstructor->Reconstruct(fRunLoader);
     }
-    AliInfo(Form("Execution time for %s: R:%.2fs C:%.2fs",
-                fgkDetectorName[iDet],
-                stopwatchDet.RealTime(),stopwatchDet.CpuTime()));
+     
+     AliCodeTimerStop(Form("running reconstruction for %s", fgkDetectorName[iDet]));
 
     // unload calibration data
     man->UnloadFromCache(calibPath);
@@ -872,9 +869,6 @@ Bool_t AliReconstruction::RunLocalReconstruction(const TString& detectors)
     if (fStopOnError) return kFALSE;
   }
 
-  AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-              stopwatch.RealTime(),stopwatch.CpuTime()));
-
   return kTRUE;
 }
 
@@ -883,8 +877,7 @@ Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
 {
 // run the local reconstruction
 
-  TStopwatch stopwatch;
-  stopwatch.Start();
+  AliCodeTimerAuto("")
 
   TString detStr = detectors;
   for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
@@ -897,8 +890,8 @@ Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
     if (fRawReader && reconstructor->HasDigitConversion()) {
       AliInfo(Form("converting raw data digits into root objects for %s", 
                   fgkDetectorName[iDet]));
-      TStopwatch stopwatchDet;
-      stopwatchDet.Start();
+      AliCodeTimerAuto(Form("converting raw data digits into root objects for %s", 
+                            fgkDetectorName[iDet]));
       loader->LoadDigits("update");
       loader->CleanDigits();
       loader->MakeDigitsContainer();
@@ -906,16 +899,12 @@ Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
       reconstructor->ConvertDigits(fRawReader, digitsTree);
       loader->WriteDigits("OVERWRITE");
       loader->UnloadDigits();
-      AliInfo(Form("Execution time for %s: R:%.2fs C:%.2fs",
-                  fgkDetectorName[iDet],
-                  stopwatchDet.RealTime(),stopwatchDet.CpuTime()));
     }
 
     // local reconstruction
     if (!reconstructor->HasLocalReconstruction()) continue;
     AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet]));
-    TStopwatch stopwatchDet;
-    stopwatchDet.Start();
+    AliCodeTimerAuto(Form("running reconstruction for %s", fgkDetectorName[iDet]));
     loader->LoadRecPoints("update");
     loader->CleanRecPoints();
     loader->MakeRecPointsContainer();
@@ -935,9 +924,6 @@ Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
     }
     loader->WriteRecPoints("OVERWRITE");
     loader->UnloadRecPoints();
-    AliInfo(Form("Execution time for %s: R:%.2fs C:%.2fs",
-                fgkDetectorName[iDet],
-                stopwatchDet.RealTime(),stopwatchDet.CpuTime()));
   }
 
   if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
@@ -946,9 +932,6 @@ Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
     if (fStopOnError) return kFALSE;
   }
   
-  AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-              stopwatch.RealTime(),stopwatch.CpuTime()));
-
   return kTRUE;
 }
 
@@ -957,8 +940,7 @@ Bool_t AliReconstruction::RunVertexFinder(AliESD*& esd)
 {
 // run the barrel tracking
 
-  TStopwatch stopwatch;
-  stopwatch.Start();
+  AliCodeTimerAuto("")
 
   AliESDVertex* vertex = NULL;
   Double_t vtxPos[3] = {0, 0, 0};
@@ -1006,9 +988,6 @@ Bool_t AliReconstruction::RunVertexFinder(AliESD*& esd)
   }  
   delete vertex;
 
-  AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-              stopwatch.RealTime(),stopwatch.CpuTime()));
-
   return kTRUE;
 }
 
@@ -1017,8 +996,7 @@ Bool_t AliReconstruction::RunHLTTracking(AliESD*& esd)
 {
 // run the HLT barrel tracking
 
-  TStopwatch stopwatch;
-  stopwatch.Start();
+  AliCodeTimerAuto("")
 
   if (!fRunLoader) {
     AliError("Missing runLoader!");
@@ -1066,9 +1044,6 @@ Bool_t AliReconstruction::RunHLTTracking(AliESD*& esd)
     delete tracker;
   }
 
-  AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-              stopwatch.RealTime(),stopwatch.CpuTime()));
-
   return kTRUE;
 }
 
@@ -1077,8 +1052,7 @@ Bool_t AliReconstruction::RunMuonTracking(AliESD*& esd)
 {
 // run the muon spectrometer tracking
 
-  TStopwatch stopwatch;
-  stopwatch.Start();
+  AliCodeTimerAuto("")
 
   if (!fRunLoader) {
     AliError("Missing runLoader!");
@@ -1129,9 +1103,6 @@ Bool_t AliReconstruction::RunMuonTracking(AliESD*& esd)
 
   delete tracker;
   
-  AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-              stopwatch.RealTime(),stopwatch.CpuTime()));
-
   return kTRUE;
 }
 
@@ -1141,8 +1112,7 @@ Bool_t AliReconstruction::RunTracking(AliESD*& esd)
 {
 // run the barrel tracking
 
-  TStopwatch stopwatch;
-  stopwatch.Start();
+  AliCodeTimerAuto("")
 
   AliInfo("running tracking");
 
@@ -1258,9 +1228,6 @@ Bool_t AliReconstruction::RunTracking(AliESD*& esd)
     track->RelateToVertex(esd->GetVertex(),fieldZ, kMaxD);
   }
   
-  AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-              stopwatch.RealTime(),stopwatch.CpuTime()));
-
   return kTRUE;
 }
 
@@ -1269,9 +1236,7 @@ Bool_t AliReconstruction::FillESD(AliESD*& esd, const TString& detectors)
 {
 // fill the event summary data
 
-  TStopwatch stopwatch;
-  stopwatch.Start();
-  AliInfo("filling ESD");
+  AliCodeTimerAuto("")
 
   TString detStr = detectors;
   for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
@@ -1326,9 +1291,6 @@ Bool_t AliReconstruction::FillESD(AliESD*& esd, const TString& detectors)
     if (fStopOnError) return kFALSE;
   }
 
-  AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-              stopwatch.RealTime(),stopwatch.CpuTime()));
-
   return kTRUE;
 }
 
@@ -1339,6 +1301,8 @@ Bool_t AliReconstruction::FillTriggerESD(AliESD*& esd)
   // stored in Trigger.root file and fills
   // the corresponding esd entries
 
+  AliCodeTimerAuto("")
+  
   AliInfo("Filling trigger information into the ESD");
 
   if (fRawReader) {
index aaac23f1606c460e8ecdc0f7afcbabf13f157ed2..57ff80506e8c93637d2bfa4e61e4bd1d17301480 100644 (file)
 #include <TVirtualMCApplication.h>
 #include <TGeoManager.h>
 #include <TObjString.h>
-#include <TStopwatch.h>
 #include <TSystem.h>
 #include <TFile.h>
 
+#include "AliCodeTimer.h"
 #include "AliCDBStorage.h"
 #include "AliCDBEntry.h"
 #include "AliCDBManager.h"
@@ -249,6 +249,8 @@ AliSimulation::~AliSimulation()
 
   fSpecCDBUri.Delete();
   if (fgInstance==this) fgInstance = 0;
+
+  AliCodeTimer::Instance()->Print();
 }
 
 
@@ -474,6 +476,8 @@ Bool_t AliSimulation::Run(Int_t nEvents)
 {
 // run the generation, simulation and digitization
 
+  AliCodeTimerAuto("")
+  
   InitCDBStorage();
 
   if (nEvents > 0) fNEvents = nEvents;
@@ -541,8 +545,7 @@ Bool_t AliSimulation::RunTrigger(const char* descriptors)
 {
   // run the trigger
 
-   TStopwatch stopwatch;
-   stopwatch.Start();
+  AliCodeTimerAuto("")
 
    AliRunLoader* runLoader = LoadRun("READ");
    if (!runLoader) return kFALSE;
@@ -571,9 +574,6 @@ Bool_t AliSimulation::RunTrigger(const char* descriptors)
       }
    }
 
-   AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-           stopwatch.RealTime(),stopwatch.CpuTime()));
-
    delete runLoader;
 
    return kTRUE;
@@ -596,8 +596,7 @@ Bool_t AliSimulation::RunSimulation(Int_t nEvents)
 {
 // run the generation and simulation
 
-  TStopwatch stopwatch;
-  stopwatch.Start();
+  AliCodeTimerAuto("")
 
   if (!gAlice) {
     AliError("no gAlice object. Restart aliroot and try again.");
@@ -707,8 +706,6 @@ Bool_t AliSimulation::RunSimulation(Int_t nEvents)
 
   delete runLoader;
 
-  AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-              stopwatch.RealTime(),stopwatch.CpuTime()));
 
   return kTRUE;
 }
@@ -718,8 +715,7 @@ Bool_t AliSimulation::RunSDigitization(const char* detectors)
 {
 // run the digitization and produce summable digits
 
-  TStopwatch stopwatch;
-  stopwatch.Start();
+  AliCodeTimerAuto("")
 
   AliRunLoader* runLoader = LoadRun();
   if (!runLoader) return kFALSE;
@@ -731,11 +727,8 @@ Bool_t AliSimulation::RunSDigitization(const char* detectors)
     if (!det || !det->IsActive()) continue;
     if (IsSelected(det->GetName(), detStr)) {
       AliInfo(Form("creating summable digits for %s", det->GetName()));
-      TStopwatch stopwatchDet;
-      stopwatchDet.Start();
+      AliCodeTimerAuto(Form("creating summable digits for %s", det->GetName()));
       det->Hits2SDigits();
-      AliInfo(Form("Execution time for %s: R:%.2fs C:%.2fs",
-          det->GetName(),stopwatchDet.RealTime(),stopwatchDet.CpuTime()));
     }
   }
 
@@ -747,9 +740,6 @@ Bool_t AliSimulation::RunSDigitization(const char* detectors)
 
   delete runLoader;
 
-  AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-          stopwatch.RealTime(),stopwatch.CpuTime()));
-
   return kTRUE;
 }
 
@@ -760,8 +750,7 @@ Bool_t AliSimulation::RunDigitization(const char* detectors,
 {
 // run the digitization and produce digits from sdigits
 
-  TStopwatch stopwatch;
-  stopwatch.Start();
+  AliCodeTimerAuto("")
 
   while (AliRunLoader::GetRunLoader()) delete AliRunLoader::GetRunLoader();
   if (gAlice) delete gAlice;
@@ -814,9 +803,6 @@ Bool_t AliSimulation::RunDigitization(const char* detectors,
 
   delete manager;
 
-  AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-              stopwatch.RealTime(),stopwatch.CpuTime()));
-  
   return kTRUE;
 }
 
@@ -825,8 +811,7 @@ Bool_t AliSimulation::RunHitsDigitization(const char* detectors)
 {
 // run the digitization and produce digits from hits
 
-  TStopwatch stopwatch;
-  stopwatch.Start();
+  AliCodeTimerAuto("")
 
   AliRunLoader* runLoader = LoadRun("READ");
   if (!runLoader) return kFALSE;
@@ -852,9 +837,6 @@ Bool_t AliSimulation::RunHitsDigitization(const char* detectors)
   //PH Temporary fix to avoid interference with the PHOS loder/getter
   //PH The problem has to be solved in more general way 09/06/05
 
-  AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-              stopwatch.RealTime(),stopwatch.CpuTime()));
-
   return kTRUE;
 }
 
@@ -872,8 +854,7 @@ Bool_t AliSimulation::WriteRawData(const char* detectors,
 // to a root file.
 // If deleteIntermediateFiles is true, the DATE file is deleted afterwards.
 
-  TStopwatch stopwatch;
-  stopwatch.Start();
+  AliCodeTimerAuto("")
 
   if (!WriteRawFiles(detectors)) {
     if (fStopOnError) return kFALSE;
@@ -906,9 +887,6 @@ Bool_t AliSimulation::WriteRawData(const char* detectors,
     }
   }
 
-  AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-              stopwatch.RealTime(),stopwatch.CpuTime()));
-
   return kTRUE;
 }
 
@@ -917,6 +895,8 @@ Bool_t AliSimulation::WriteRawFiles(const char* detectors)
 {
 // convert the digits to raw data DDL files
 
+  AliCodeTimerAuto("")
+  
   AliRunLoader* runLoader = LoadRun("READ");
   if (!runLoader) return kFALSE;
 
@@ -956,6 +936,7 @@ Bool_t AliSimulation::WriteRawFiles(const char* detectors)
   }
 
   delete runLoader;
+  
   return kTRUE;
 }
 
@@ -964,6 +945,8 @@ Bool_t AliSimulation::ConvertRawFilesToDate(const char* dateFileName)
 {
 // convert raw data DDL files to a DATE file with the program "dateStream"
 
+  AliCodeTimerAuto("")
+  
   char* path = gSystem->Which(gSystem->Getenv("PATH"), "dateStream");
   if (!path) {
     AliError("the program dateStream was not found");
index 12278568c84cd13fff5ad06dfad34375ef4b9c74..c27079e7ba7f1b2b6780c58a7d63c31e06f94a1e 100644 (file)
 #pragma link C++ class AliSurveyObj+;
 #pragma link C++ class AliSurveyPoint+;
 
+#pragma link C++ class AliCodeTimer+;
+#pragma link C++ class AliCodeTimer::AliPair+;
+
 #endif
index 8424e664cd0e8ecc6737d9b3cc7751cb2cf0b72b..85d7829ef4749f8f52185ac8f8ccd159c0bab2ae 100644 (file)
@@ -40,7 +40,9 @@ AliHelix.cxx AliV0.cxx AliKink.cxx \
 AliSelectorRL.cxx AliSplineFit.cxx \
 AliMagFMapsV1.cxx \
 AliDCSValue.cxx AliDCSSensor.cxx AliDCSSensorArray.cxx \
-AliSurveyObj.cxx AliSurveyPoint.cxx
+AliSurveyObj.cxx AliSurveyPoint.cxx \
+AliCodeTimer.cxx
+
 
 
 HDRS:= $(SRCS:.cxx=.h)