LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
timer.hh
Go to the documentation of this file.
1 
6 #ifndef MISC_TIMER_HH
7 # define MISC_TIMER_HH
8 
9 # include <iostream>
10 # include <stack>
11 # include <map>
12 # include <string>
13 # include <iosfwd>
14 
15 namespace misc
16 {
17 
19  class timer
20  {
21  public:
22  timer();
23  timer(const timer& rhs);
24  ~timer();
25 
28  void push(const std::string& name);
29 
33  void push(int i);
34 
38  void pop(const std::string& task_name);
39 
42  void pop(int i);
43 
45  void pop();
46 
49  void dump(std::ostream& out = std::cerr);
50 
53  void dump_on_destruction(std::ostream& out);
54 
56  void name(int i, const std::string& task_name);
57 
60  void start();
61 
64  void stop();
65 
72  timer& operator<<(const timer& rhs);
73 
74  private :
75  class time_var;
76  class time
77  {
78  friend class timer;
79  friend class timer::time_var;
80  public:
81  time();
82 
83  time & operator+=(const time& rhs);
84 
85  private :
86  long user;
87  long sys;
88  long wall;
89  };
90 
91  class time_var
92  {
93  public:
94  time_var();
95 
96  void start();
97  void stop();
98 
99  bool is_zero();
100 
105  bool initial;
106  };
107 
109  void timeinfo(long time, long total_time, std::ostream& out);
110 
111  typedef std::map<const std::string, time_var*> task_map_type;
112 
115 
117  std::stack<time_var*> tasks;
118 
121  std::map<int, std::string> intmap;
122 
127 
131  std::ostream* dump_stream;
132 
135  static const long clocks_per_sec;
136 
137  };
138 
139 } // namespace misc
140 
141 # include <misc/timer.hxx>
142 
143 #endif // !MISC_TIMER_HH