diff mbox

[i-g-t,3/4] flip_test: use monotonic time to measure the test duration

Message ID 1353590706-1366-4-git-send-email-imre.deak@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Imre Deak Nov. 22, 2012, 1:25 p.m. UTC
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 tests/flip_test.c |   16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

Comments

Daniel Vetter Nov. 22, 2012, 1:52 p.m. UTC | #1
On Thu, Nov 22, 2012 at 03:25:05PM +0200, Imre Deak wrote:
> Signed-off-by: Imre Deak <imre.deak@intel.com>

Merged patches 1-3, thanks.
-Daniel
diff mbox

Patch

diff --git a/tests/flip_test.c b/tests/flip_test.c
index e2af358..d88f81c 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -786,15 +786,11 @@  static unsigned int wait_for_events(struct test_output *o)
 /* Returned the ellapsed time in us */
 static unsigned event_loop(struct test_output *o, unsigned duration_sec)
 {
-	struct timeval start, end;
-	struct timeval tv_dur;
+	unsigned long start, end;
 
-	gettimeofday(&start, NULL);
-	end.tv_sec = start.tv_sec + duration_sec;
-	end.tv_usec = start.tv_usec;
+	start = gettime_us();
 
 	while (1) {
-		struct timeval now;
 		unsigned int completed_events;
 
 		completed_events = run_test_step(o);
@@ -803,19 +799,17 @@  static unsigned event_loop(struct test_output *o, unsigned duration_sec)
 		check_all_state(o, completed_events);
 		update_all_state(o, completed_events);
 
-		gettimeofday(&now, NULL);
-		if (!timercmp(&now, &end, <))
+		if ((gettime_us() - start) / 1000000 >= duration_sec)
 			break;
 	}
 
-	gettimeofday(&end, NULL);
-	timersub(&end, &start, &tv_dur);
+	end = gettime_us();
 
 	/* Flush any remaining events */
 	if (o->pending_events)
 		wait_for_events(o);
 
-	return tv_dur.tv_sec * 1000 * 1000 + tv_dur.tv_usec;
+	return end - start;
 }
 
 static void run_test_on_crtc(struct test_output *o, int crtc, int duration)