MultiAgentDecisionProcess  Release 0.2.1
Timing.h
Go to the documentation of this file.
1 
28 /* Only include this header file once. */
29 #ifndef _TIMING_H_
30 #define _TIMING_H_ 1
31 
32 /* the include directives */
33 #include <iostream>
34 #include "Globals.h"
35 
36 #include <time.h>
37 #include <string>
38 #include <map>
39 #include <vector>
40 
41 
42 
44 class Timing
45 {
46 private:
47 
49  struct Times {
50  clock_t start, end;
51  bool hasEnded;
52  };
53 
55  std::map <std::string, std::vector<Times> > _m_timesMap;
56 
59 
60  clock_t GetCpuTime() const;
61 
62  double ClockToSeconds(clock_t clockTicks) const;
63 
64  void Stop(const std::string & id, clock_t duration);
65 
66 protected:
67 
68 public:
69  // Constructor, destructor and copy assignment.
71  Timing();
73  ~Timing();
74 
76  void Start(const std::string & id);
77 
79  void Stop(const std::string & id);
80 
82  void Print() const;
83 
85  void PrintSummary() const;
86 
88  void Save(const std::string & filename) const;
89 
91  void Save(std::ofstream &of) const;
92 
94  void Load(const std::string & filename);
95 
97  void AddEvent(const std::string & id, clock_t duration);
98 
100  std::vector<double> GetEventDurations(const std::string & id);
101 };
102 
103 
104 #endif /* !_TIMING_H_ */
105 
106 // Local Variables: ***
107 // mode:c++ ***
108 // End: ***