MpdCodeTimer.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef MPDCODETIMER_H
  2. #define MPDCODETIMER_H
  3. /// \ingroup rec
  4. /// \class MpdCodeTimer
  5. /// \brief MPD code timing utility class.
  6. ///
  7. /// \author Mariya Ilieva, LHEP JINR Dubna
  8. #include "FairRun.h"
  9. #include "FairTask.h"
  10. #include <TString.h>
  11. //#include <map>
  12. //#include "TMVA/Timer.h"
  13. #include <TMap.h>
  14. class TStopwatch;
  15. class MpdCodeTimer : public FairTask
  16. {
  17. public:
  18. // KG public cpnstructor for TStreamer reading
  19. MpdCodeTimer(const char *name="MpdCodeTimer", const char *title="MPD Task"); ///< Ctor
  20. static MpdCodeTimer* Instance(); ///< get singleton instance
  21. static MpdCodeTimer* Instance(const char *name, const char *title="MPD Task"); ///< get singleton instance
  22. static MpdCodeTimer* Active() { return (MpdCodeTimer*) FairRun::Instance()->GetTask("Code timer"); } ///< get singleton instance
  23. virtual void Exec(Option_t * option);
  24. //void Init(Int_t counter);
  25. void Reset();
  26. void Register();
  27. void Start(const TString classname, const TString method);
  28. void Stop(const TString classname, const TString method);
  29. void Print();
  30. protected:
  31. virtual InitStatus Init();
  32. virtual InitStatus ReInit();
  33. virtual void Finish();
  34. virtual ~MpdCodeTimer(); ///< Destructor
  35. private:
  36. // automatic deleting when application exit
  37. static void DestroyInstance (){
  38. if (fgCT)
  39. delete fgCT;
  40. }
  41. void Print(TStopwatch *sw, Option_t *opt); // print info from TStopwatch
  42. static MpdCodeTimer* fgCT; //! pointer to Singleton instance, may be ! required to exclude recursion
  43. private:
  44. TMap fTimeMap; // class-method map
  45. ClassDef(MpdCodeTimer,1);
  46. };
  47. #endif