profiler.h
Go to the documentation of this file.
1 
6 #ifndef PROFILER_H
7 #define PROFILER_H
8 
9 #include <sys/time.h>
10 #include <sys/resource.h>
11 #include <pthread.h>
12 
13 #include <string>
14 #include <iostream>
15 #include <fstream>
16 #include <vector>
17 
18 namespace argos {
19 
20  class CProfiler {
21 
22  public:
23 
24  CProfiler(const std::string& str_file_name,
25  bool b_trunc=true);
26  ~CProfiler();
27 
28  void Start();
29  void Stop();
30  void Flush(bool b_human_readable);
32 
33  private:
34 
35  void StartWallClock();
36  void StopWallClock();
37 
38  void StartCPUProfiler();
39  void StopCPUProfiler();
40 
41  void FlushHumanReadable();
42  void FlushAsTable();
43 
44  private:
45 
46  std::ofstream m_cOutFile;
47  ::timeval m_tWallClockStart;
48  ::timeval m_tWallClockEnd;
49  ::rusage m_tResourceUsageStart;
50  ::rusage m_tResourceUsageEnd;
51  std::vector< ::rusage > m_vecThreadResourceUsage;
52  pthread_mutex_t m_tThreadResourceUsageMutex;
53 
54  };
55 
56 }
57 
58 #endif
void CollectThreadResourceUsage()
Definition: profiler.cpp:172
CProfiler(const std::string &str_file_name, bool b_trunc=true)
Definition: profiler.cpp:116
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
void Flush(bool b_human_readable)
Definition: profiler.cpp:160