20 #include <freerdp/config.h>
25 #include <freerdp/utils/profiler.h>
26 #include <freerdp/log.h>
28 #define TAG FREERDP_TAG("utils")
36 PROFILER* profiler_create(
const char* name)
38 PROFILER* profiler = (PROFILER*)calloc(1,
sizeof(PROFILER));
43 profiler->name = _strdup(name);
44 profiler->stopwatch = stopwatch_create();
46 if (!profiler->name || !profiler->stopwatch)
51 profiler_free(profiler);
55 void profiler_free(PROFILER* profiler)
60 stopwatch_free(profiler->stopwatch);
66 void profiler_enter(PROFILER* profiler)
68 stopwatch_start(profiler->stopwatch);
71 void profiler_exit(PROFILER* profiler)
73 stopwatch_stop(profiler->stopwatch);
76 void profiler_print_header(
void)
79 "-------------------------------+------------+-------------+-----------+-------");
81 "PROFILER NAME | COUNT | TOTAL | AVG | IPS");
83 "-------------------------------+------------+-------------+-----------+-------");
86 void profiler_print(PROFILER* profiler)
88 double s = stopwatch_get_elapsed_time_in_seconds(profiler->stopwatch);
89 double avg = profiler->stopwatch->count == 0 ? 0 : s / profiler->stopwatch->count;
90 WLog_INFO(TAG,
"%-30s | %10u | %10.4fs | %8.6fs | %6.0f", profiler->name,
91 profiler->stopwatch->count, s, avg, profiler->stopwatch->count / s);
94 void profiler_print_footer(
void)
97 "-------------------------------+------------+-------------+-----------+-------");