void profiler_total_report(void) { Double total = PROFILER_TO_SEC(profile_total); Double render = PROFILER_TO_SEC(profile_render); Double present = PROFILER_TO_SEC(profile_present); Double cairo = PROFILER_TO_SEC(profile_cairo); if (total == 0) { fprintf(log_output, "total: %f\n", total); } else { fprintf(log_output, "total: %f (%.0f%%), render: %.0f%%, present: %.0f%%, cairo: %.0f%% %i\n", total, (total / (1.0 / OPTION_FPS)) * 100 , render/total * 100.0, present/total * 100.0, cairo/total * 100.0, profile_cairo -> count); } profiler_reset(profile_total); profiler_reset(profile_render); profiler_reset(profile_present); profiler_reset(profile_cairo); }
void profiler_report(Profile *profile) { if (!(profile -> time.tv_sec == 0 && profile -> time.tv_nsec == 0)) { fprintf(log_output, "profile %s %llds %lldns, count %d, %lld.%fns\n", profile -> name, (long long) profile -> time.tv_sec, (long long) profile -> time.tv_nsec, profile -> count, (long long) profile -> time.tv_sec / profile -> count, ((double) profile -> time.tv_nsec / profile -> count)/1000000000.0 ); } profiler_reset(profile); }
/** * @brief Generic routine for profiler error output * @param file Generally called with __FILE__ (gcc), contains the file name where allocation is done * @param func Generally called with __FUNCTION__ (gcc), contains the function name where allocation is done * @param line Generally called with __LINE__ (gcc), contains the line number in related file * @param msg Profiling message suffix to be printed */ void profiler_err(char *file, char *func, u_int line, char *msg) { char buff[80]; char buf[BUFSIZ]; char *fill; if (!(aspectworld.proflevel & PROFILE_WARN)) return; /* Stock a pattern without printing */ if (profiler_print(file, func, line, msg)) return; fill = (profiler_depth - 6 > 0 ? alloca(profiler_depth + 1) : ""); if (profiler_depth - 6 > 0) { memset(fill, ' ', profiler_depth); fill[profiler_depth] = 0x00; } if (aspectworld.endline != NULL) { snprintf(buff, sizeof(buff), " <%s@%s:%s>", aspectworld.colorfunction(func), aspectworld.colorfilename(file), aspectworld.colornumber("%u", line)); snprintf(buf, BUFSIZ, " %s %s %-70s %s \n", aspectworld.colorwarn("[W]"), fill, buff, aspectworld.colorwarn(msg)); } else { snprintf(buff, sizeof(buff), " <%s@%s:%u>", func, file, line); snprintf(buf, BUFSIZ, " [W] %s %-70s %s \n", fill, buff, msg); } if (aspectworld.profile_err != NULL) aspectworld.profile_err(buf); else fprintf(stderr, "No profiling function specified.\n"); if (aspectworld.endline != NULL) aspectworld.endline(); profiler_reset(0); }