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>();
56 if (
mode == CPU_TIME) {
60 }
else if (
mode == REAL_TIME) {
66 LARGE_INTEGER intervals;
70 GetSystemTimeAsFileTime(&ft);
71 intervals.LowPart = ft.dwLowDateTime;
72 intervals.HighPart = ft.dwHighDateTime;
74 long double measure = intervals.QuadPart;
75 measure -= 116444736000000000.0;
76 measure /= 10000000.0;
82 gettimeofday(&tv, NULL);
84 long double measure = tv.tv_usec;
129 long double lapse = clock_end - perf_info.
clock_start;
131 if (
mode == CPU_TIME) lapse /= (double)CLOCKS_PER_SEC;
147 long double clock_end = clock();
157 long double lapse = clock_end - perf_info.
clock_start;
167 map<string, PerformanceData>::iterator it;
177 output <<
"\n" << std::setw(STOP_WATCH_MAX_NAME_LENGTH) << std::left <<
"*** PROFILING RESULTS [ms] ";
178 output << std::setw(STOP_WATCH_TIME_WIDTH) <<
"min"
180 output << std::setw(STOP_WATCH_TIME_WIDTH) <<
"avg"
182 output << std::setw(STOP_WATCH_TIME_WIDTH) <<
"max"
184 output << std::setw(STOP_WATCH_TIME_WIDTH) <<
"lastTime"
186 output << std::setw(STOP_WATCH_TIME_WIDTH) <<
"nSamples"
188 output << std::setw(STOP_WATCH_TIME_WIDTH) <<
"totalTime"
190 map<string, PerformanceData>::iterator it;
192 if (it->second.stops > 0)
report(it->first, precision, output);
214 std::cout <<
"Stopwatch active." << std::endl;
219 std::cout <<
"Stopwatch inactive." << std::endl;
231 output << std::setw(STOP_WATCH_MAX_NAME_LENGTH) << std::left << perf_name;
232 output << std::fixed << std::setprecision(precision) << std::setw(STOP_WATCH_TIME_WIDTH)
233 << (perf_info.
min_time * 1e3) <<
" ";
234 output << std::fixed << std::setprecision(precision) << std::setw(STOP_WATCH_TIME_WIDTH)
236 output << std::fixed << std::setprecision(precision) << std::setw(STOP_WATCH_TIME_WIDTH)
237 << (perf_info.
max_time * 1e3) <<
" ";
238 output << std::fixed << std::setprecision(precision) << std::setw(STOP_WATCH_TIME_WIDTH)
240 output << std::fixed << std::setprecision(precision) << std::setw(STOP_WATCH_TIME_WIDTH) << perf_info.
stops <<
" ";
241 output << std::fixed << std::setprecision(precision) << std::setw(STOP_WATCH_TIME_WIDTH)
251 if (
mode == CPU_TIME) lapse /= (double)CLOCKS_PER_SEC;