[Piglit] [PATCH] ext_timer_query-time-elapsed: make results more reliable
Vadim Girlin
vadimgirlin at gmail.com
Fri Aug 31 13:01:19 PDT 2012
The test results aren't very reliable depending on the current cpu/gpu load
etc, so it fails sometimes with r600g. AFAICS it's not expected to be running
concurrently with other apps/tests.
We can decrease the effect of high cpu load by using clock() instead of
gettimeofday().
---
The problem is reproducible for me with r600g and ~10 of
"vblank_mode=0 glxgears" running in parallel - 10 of 10 test runs failed.
With this patch 10 of 10 test runs passed.
tests/spec/ext_timer_query/time-elapsed.c | 21 +++------------------
1 file changed, 3 insertions(+), 18 deletions(-)
diff --git a/tests/spec/ext_timer_query/time-elapsed.c b/tests/spec/ext_timer_query/time-elapsed.c
index ce27ce0..9350ca9 100644
--- a/tests/spec/ext_timer_query/time-elapsed.c
+++ b/tests/spec/ext_timer_query/time-elapsed.c
@@ -29,7 +29,7 @@
* Test TIME_ELAPSED and TIMESTAMP queries.
*/
-#include <sys/time.h>
+#include <time.h>
PIGLIT_GL_TEST_MAIN(
128 /*window_width*/,
@@ -44,23 +44,8 @@ enum {
static float
get_time(void)
{
- static bool inited = false;
- static time_t base_sec = 0;
- struct timeval tv;
-
- gettimeofday(&tv, NULL);
-
- /* Return a value that is roughly seconds since program
- * startup, to avoid large tv_sec reducing precision of the
- * return value.
- */
- if (!inited) {
- inited = true;
- base_sec = tv.tv_sec;
- }
- tv.tv_sec -= base_sec;
-
- return (double)tv.tv_sec + tv.tv_usec / 1000000.0;
+ clock_t clk = clock();
+ return ((double)clk) / CLOCKS_PER_SEC;
}
static float
--
1.7.11.4
More information about the Piglit
mailing list