code_profiler
profiler.h
Go to the documentation of this file.
1 #ifndef TUE_CODE_PROFILER_PROFILING_PROFILER_H_
2 #define TUE_CODE_PROFILER_PROFILING_PROFILER_H_
3 
4 #include <string>
5 #include <map>
6 #include "timer.h"
7 
8 namespace tue
9 {
10 
11 class Profiler
12 {
13 
14 public:
15 
16  Profiler();
17 
18  Profiler(const std::string& name);
19 
20  virtual ~Profiler();
21 
22  void setName(const std::string& name) { name_ = name; }
23 
24  const std::string& getName() const { return name_; }
25 
26  void startTimer(const std::string& name);
27 
28  void stopTimer();
29 
30  friend std::ostream& operator<< (std::ostream& out, const Profiler& p);
31 
32 protected:
33 
35 
37 
39 
41 
43 
44  Profiler(const std::string& name, Profiler* parent);
45 
46  void addToStream(std::ostream& out, const std::string& prefix = "") const;
47 
48 };
49 
50 }
51 
52 #endif
std::string
tue::Profiler::timer_
Timer timer_
Definition: profiler.h:40
tue::Profiler::head_
Profiler * head_
Definition: profiler.h:36
tue::Profiler::stopTimer
void stopTimer()
Definition: profiler.cpp:64
tue::Profiler::Profiler
Profiler()
Definition: profiler.cpp:10
tue::Profiler::getName
const std::string & getName() const
Definition: profiler.h:24
tue::Profiler::startTimer
void startTimer(const std::string &name)
Definition: profiler.cpp:38
tue::Profiler::parent_
Profiler * parent_
Definition: profiler.h:38
tue::Profiler::name_
std::string name_
Definition: profiler.h:34
std::ostream
timer.h
tue::Profiler::addToStream
void addToStream(std::ostream &out, const std::string &prefix="") const
Definition: profiler.cpp:78
map
tue::Timer
Definition: timer.h:30
tue::Profiler
Definition: profiler.h:11
tue::Profiler::children_
std::map< std::string, Profiler * > children_
Definition: profiler.h:42
tue::Profiler::operator<<
friend std::ostream & operator<<(std::ostream &out, const Profiler &p)
Definition: profiler.cpp:97
tue::Profiler::~Profiler
virtual ~Profiler()
Definition: profiler.cpp:28
tue
Definition: loop_timer.h:8
tue::Profiler::setName
void setName(const std::string &name)
Definition: profiler.h:22
string