double ymax = 0;
int r;
+ // Measure the runtime
+ clock_t t_start = 0;
+ clock_t t_end = 0;
+
// Log action
DEBUG(self->ctx, "Rendering %s...\n", collecty_graph_get_name(self));
if (!self->impl->render)
return -ENOTSUP;
+ // Store the start time
+ t_start = clock();
+ if (t_start < 0) {
+ ERROR(self->ctx, "clock() has failed: %m\n");
+ r = -errno;
+ goto ERROR;
+ }
+
// Open a file handle to the output buffer
f = open_memstream(buffer, length);
if (!f) {
goto ERROR;
}
+ // Store the end time
+ t_end = clock();
+ if (t_end < 0) {
+ ERROR(self->ctx, "clock() has failed: %m\n");
+ r = -errno;
+ goto ERROR;
+ }
+
// Log action
- DEBUG(self->ctx, "Rendered graph %s:\n", collecty_graph_get_name(self));
+ DEBUG(self->ctx, "Rendered graph %s in %.2fms:\n",
+ collecty_graph_get_name(self), (double)(t_end - t_start) / CLOCKS_PER_SEC * 1000);
DEBUG(self->ctx, " size : %d byte(s)\n", ftell(f));
DEBUG(self->ctx, " width : %d\n", w);
DEBUG(self->ctx, " height : %d\n", h);