From 383fc95ff68a2b9a2772e2b12febb1830c32e260 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 12 Nov 2013 10:20:10 -0800 Subject: [PATCH] Fix CPU load reported on initial frame. We were seeing a result like this: frame: 0 21.0526 20.9131 -4.54586e+17 0 while the frame obviously didn't take negative time. The bug was subtracting an unintialized metrics->previous_cpu_time_ts. In order to have this in place by the end of the first frame, we need to do an initial query of the CPU time when first creating our metrics object, (before starting the first frame). Thanks to Eric Anholt for identifying this bug. --- metrics.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/metrics.c b/metrics.c index 1c8a973..36ef90b 100644 --- a/metrics.c +++ b/metrics.c @@ -144,6 +144,9 @@ metrics_create (metrics_info_t *info) /* Get the first frame timestamp started immediately. */ glQueryCounter (metrics->swap_end_timestamp_id, GL_TIMESTAMP); + /* As well as the initial CPU time. */ + clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &metrics->cpu_time_ts); + return metrics; } -- 2.43.0