ToolDAQFramework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Stopwatch.h
Go to the documentation of this file.
1 #ifndef STOPWATCH_H
2 #define STOPWATCH_H
3 
4 #include <string>
5 #include <vector>
6 #include <sstream>
7 
8 #include "TStopwatch.h"
9 
10 namespace util {
11 
12  struct StopwatchTimes {
13  double cpu_time;
14  double real_time;
15  };
16 
17  class Stopwatch {
18  public:
19 
20  Stopwatch(const char * tool_name);
21 
23  void Start();
28  std::string Result(std::string method_name, std::string output_file = "");
30  void Reset();
31 
32  private:
34  TStopwatch m_sw;
36  std::vector<StopwatchTimes> m_results;
38  bool m_running;
39 
41  std::string m_tool_name;
42 
43  };
44 
45 } //util
46 
47 #endif //STOPWATCH_H
std::string Result(std::string method_name, std::string output_file="")
Definition: Stopwatch.cpp:38
void Start()
Start the stopwatch.
Definition: Stopwatch.cpp:18
StopwatchTimes Stop()
Stop the stopwatch, returning the CPU time.
Definition: Stopwatch.cpp:24
std::vector< StopwatchTimes > m_results
Stores time at every Stop.
Definition: Stopwatch.h:36
Stopwatch(const char *tool_name)
Definition: Stopwatch.cpp:12
void Reset()
Stop the stopwatch, and clear the results vector.
Definition: Stopwatch.cpp:108
std::string output_file
Definition: library_daq.h:200
TStopwatch m_sw
The external stopwatch timer.
Definition: Stopwatch.h:34
bool m_running
Stores the state - running or not.
Definition: Stopwatch.h:38
std::string m_tool_name
The name of the tool using the Stopwatch. For use in printout.
Definition: Stopwatch.h:41