32 #include "crocoddyl/core/utils/stop-watch.hpp"
35 using std::ostringstream;
40 Stopwatch& getProfiler() {
41 static Stopwatch s(REAL_TIME);
46 records_of =
new map<string, PerformanceData>();
62 if (
mode == CPU_TIME) {
66 }
else if (
mode == REAL_TIME) {
72 LARGE_INTEGER intervals;
76 GetSystemTimeAsFileTime(&ft);
77 intervals.LowPart = ft.dwLowDateTime;
78 intervals.HighPart = ft.dwHighDateTime;
80 long double measure = intervals.QuadPart;
81 measure -= 116444736000000000.0;
82 measure /= 10000000.0;
88 gettimeofday(&tv, NULL);
90 long double measure = tv.tv_usec;
135 long double lapse = clock_end - perf_info.
clock_start;
137 if (
mode == CPU_TIME) lapse /= (double)CLOCKS_PER_SEC;
153 long double clock_end = clock();
163 long double lapse = clock_end - perf_info.
clock_start;
173 map<string, PerformanceData>::iterator it;
183 output <<
"\n" << std::setw(STOP_WATCH_MAX_NAME_LENGTH) << std::left <<
"*** PROFILING RESULTS [ms] ";
184 output << std::setw(STOP_WATCH_TIME_WIDTH) <<
"min"
186 output << std::setw(STOP_WATCH_TIME_WIDTH) <<
"avg"
188 output << std::setw(STOP_WATCH_TIME_WIDTH) <<
"max"
190 output << std::setw(STOP_WATCH_TIME_WIDTH) <<
"lastTime"
192 output << std::setw(STOP_WATCH_TIME_WIDTH) <<
"nSamples"
194 output << std::setw(STOP_WATCH_TIME_WIDTH) <<
"totalTime"
196 map<string, PerformanceData>::iterator it;
198 if (it->second.stops > 0)
report(it->first, precision, output);
220 std::cout <<
"Stopwatch active." << std::endl;
225 std::cout <<
"Stopwatch inactive." << std::endl;
237 output << std::setw(STOP_WATCH_MAX_NAME_LENGTH) << std::left << perf_name;
238 output << std::fixed << std::setprecision(precision) << std::setw(STOP_WATCH_TIME_WIDTH)
239 << (perf_info.
min_time * 1e3) <<
" ";
240 output << std::fixed << std::setprecision(precision) << std::setw(STOP_WATCH_TIME_WIDTH)
242 output << std::fixed << std::setprecision(precision) << std::setw(STOP_WATCH_TIME_WIDTH)
243 << (perf_info.
max_time * 1e3) <<
" ";
244 output << std::fixed << std::setprecision(precision) << std::setw(STOP_WATCH_TIME_WIDTH)
246 output << std::fixed << std::setprecision(precision) << std::setw(STOP_WATCH_TIME_WIDTH) << perf_info.
stops <<
" ";
247 output << std::fixed << std::setprecision(precision) << std::setw(STOP_WATCH_TIME_WIDTH)
257 if (
mode == CPU_TIME) lapse /= (double)CLOCKS_PER_SEC;