This class collects all function timings and produces a profiling for certain areas of the code.
More...
#include <timer.h>
- Author
- Lennart Schneiders
- Date
- 14.02.2013
Definition at line 679 of file timer.h.
◆ Profile()
Profile::Profile |
( |
const std::string & |
name | ) |
|
|
inlineexplicit |
Definition at line 681 of file timer.h.
const MFloat m_initWallTime
const MFloat m_initCpuTime
MFloat cpuTime()
Return the process cpu time (user time) (high-resolution timer - do not use clock())
◆ ~Profile()
Definition at line 32 of file timer.cpp.
32 {
33#ifdef _OPENMP
34 if(omp_get_max_threads() > 1) {
35 m_log <<
"Skipping profile output for OpenMP. FIXME: Tracer not thread-safe!" << std::endl;
36 return;
37 }
38#endif
39
42 const MFloat thresholdPercentage = 0.5;
43 stringstream sstream;
44 sstream <<
" CPU WALL FUNCTION >> profile: '" <<
m_name <<
"' <<";
45 const string header = sstream.str();
46 const MString dashes1(header.size(),
'_');
47 const MString dashes2(header.size(),
'-');
48 m_log << dashes1 << endl << header << endl << dashes2 << endl << endl;
49
52
62 if(relCpuTime < thresholdPercentage) {
63 supCounter++;
64 continue;
65 }
66 char buffer[7];
67 sprintf(buffer, "%6.2f", relCpuTime);
68 char buffer2[7];
69 sprintf(buffer2, "%6.2f", relWallTime);
70
72 counter++;
73 }
74 if(supCounter > 0) {
75 m_log <<
" ..... ..... (" << supCounter <<
" shorter timings with CPU<" << thresholdPercentage
76 << "% were suppressed)" << endl;
77 }
78 }
79 if(counter == 0) {
80 m_log <<
"No timings recorded for timer '" <<
m_name <<
"'." << endl;
81 }
82 m_log << dashes2 << endl;
85 m_log << dashes1 << endl;
86}
static MString printTime(MFloat secs)
static std::vector< FunctionTiming > s_functionTimings
std::basic_string< char > MString
◆ getTimingId()
MInt Profile::getTimingId |
( |
std::string |
name | ) |
|
|
static |
Definition at line 88 of file timer.cpp.
88 {
93 tId = i;
94 break;
95 }
96 }
97 }
98 if(tId < 0) {
101 }
102 ASSERT(tId > -1, "Non-existing timer");
103 return tId;
104}
This class counts the static execution time of a function.
◆ printTime()
Definition at line 106 of file timer.cpp.
106 {
107 stringstream time;
108 time.str("");
110 if(rem > 86400.0) {
111 const MFloat div = floor(rem / 86400.0);
112 time << ((
MInt)div) <<
" days, ";
113 rem -= div * 86400.0;
114 }
115 if(rem > 3600.0) {
116 const MFloat div = floor(rem / 3600.0);
117 time << ((
MInt)div) <<
" hours, ";
118 rem -= div * 3600.0;
119 }
120 if(rem > 60.0) {
121 const MFloat div = floor(rem / 60.0);
122 time << ((
MInt)div) <<
" mins, ";
123 rem -= div * 60.0;
124 }
125 time << rem << " secs";
126 const MString ret = time.str();
127 return ret;
128}
◆ m_initCpuTime
const MFloat Profile::m_initCpuTime |
|
private |
◆ m_initWallTime
const MFloat Profile::m_initWallTime |
|
private |
◆ m_name
◆ s_functionTimings
The documentation for this class was generated from the following files:
- /home/gitlab-runner/scratch/builds/oxpnswJ6/1/aia/m-AIA/m-AIA/src/UTIL/timer.h
- /home/gitlab-runner/scratch/builds/oxpnswJ6/1/aia/m-AIA/m-AIA/src/UTIL/timer.cpp