[Piglit] [PATCH] ext_timer_query-time-elapsed: make result more reliable v2

Vadim Girlin vadimgirlin at gmail.com
Sat Sep 1 13:17:02 PDT 2012


Measure cpu overhead for calculated number of iterations instead of a single
iteration.
---

Currently the test measures cpu overhead of the following test loop with iters=1

	for (i = 0; i < iters; i++) {
		piglit_draw_rect(-1, -1, 2, 2);
	}

and then uses that value to compensate the overhead when there are tens
of thousands of iterations, but the difference of the overhead between these
cases is probably the orders of magnitude. This patch moves the calculation of
the overhead after the calculation of "iters", and uses "iters" iterations to
measure the overhead more precisely.

 tests/spec/ext_timer_query/time-elapsed.c | 32 ++++++++++++-------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/tests/spec/ext_timer_query/time-elapsed.c b/tests/spec/ext_timer_query/time-elapsed.c
index ce27ce0..4100385 100644
--- a/tests/spec/ext_timer_query/time-elapsed.c
+++ b/tests/spec/ext_timer_query/time-elapsed.c
@@ -138,9 +138,17 @@ piglit_display(void)
 	 */
 	draw(q, 1);
 
+	/* Find a number of draw calls that takes about 1/10th of a
+	 * second.
+	 */
+retry:
+	for (iters = 1; ; iters *= 2) {
+		if (draw(q, iters) > 0.1)
+			break;
+	}
+
 	/* Figure out some baseline difference between GPU time
-	 * elapsed and CPU time elapsed for a single draw call (CPU
-	 * overhead of timer query and glFinish()).
+	 * elapsed and CPU time elapsed for the draw calls
 	 *
 	 * Note that this doesn't take into account any extra CPU time
 	 * elapsed from start to finish if multiple batchbuffers are
@@ -152,32 +160,16 @@ piglit_display(void)
 	 * hopefully avoid that, though it might be better to have
 	 * some time-consuming shader with a single draw call instead.
 	 */
+
 	cpu_overhead = 0;
 	for (i = 0; i < num_results; i++) {
-		cpu_time[i] = draw(q, 1);
+		cpu_time[i] = draw(q, iters);
 		gpu_time[i] = get_gpu_time(q);
 
 		cpu_overhead += cpu_time[i] - gpu_time[i];
 	}
 	cpu_overhead /= num_results;
 
-	/* Find a number of draw calls that takes about 1/10th of a
-	 * second.
-	 */
-retry:
-	for (iters = 1; ; iters *= 2) {
-		if (draw(q, iters) > 0.1)
-			break;
-	}
-
-	/* Now, do several runs like this so we can determine if the
-	 * timer matches up with wall time.
-	 */
-	for (i = 0; i < num_results; i++) {
-		cpu_time[i] = draw(q, iters);
-		gpu_time[i] = get_gpu_time(q);
-	}
-
 	cpu_time_mean = 0;
 	delta_mean = 0;
 	for (i = 0; i < num_results; i++) {
-- 
1.7.11.4



More information about the Piglit mailing list