flip_test: use monotonic time to measure the test duration

Signed-off-by: Imre Deak <imre.deak@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Imre Deak 2012-11-22 15:25:05 +02:00 committed by Daniel Vetter
parent 8a2593bd3c
commit b7067d6c10

View File

@ -786,15 +786,11 @@ static unsigned int wait_for_events(struct test_output *o)
/* Returned the ellapsed time in us */ /* Returned the ellapsed time in us */
static unsigned event_loop(struct test_output *o, unsigned duration_sec) static unsigned event_loop(struct test_output *o, unsigned duration_sec)
{ {
struct timeval start, end; unsigned long start, end;
struct timeval tv_dur;
gettimeofday(&start, NULL); start = gettime_us();
end.tv_sec = start.tv_sec + duration_sec;
end.tv_usec = start.tv_usec;
while (1) { while (1) {
struct timeval now;
unsigned int completed_events; unsigned int completed_events;
completed_events = run_test_step(o); 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); check_all_state(o, completed_events);
update_all_state(o, completed_events); update_all_state(o, completed_events);
gettimeofday(&now, NULL); if ((gettime_us() - start) / 1000000 >= duration_sec)
if (!timercmp(&now, &end, <))
break; break;
} }
gettimeofday(&end, NULL); end = gettime_us();
timersub(&end, &start, &tv_dur);
/* Flush any remaining events */ /* Flush any remaining events */
if (o->pending_events) if (o->pending_events)
wait_for_events(o); 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) static void run_test_on_crtc(struct test_output *o, int crtc, int duration)