From mboxrd@z Thu Jan 1 00:00:00 1970 From: Imre Deak Subject: [i-g-t PATCH 3/4] flip_test: use monotonic time to measure the test duration Date: Thu, 22 Nov 2012 15:25:05 +0200 Message-ID: <1353590706-1366-4-git-send-email-imre.deak@intel.com> References: <1353590706-1366-1-git-send-email-imre.deak@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga14.intel.com (mga14.intel.com [143.182.124.37]) by gabe.freedesktop.org (Postfix) with ESMTP id 60A23E5EB6 for ; Thu, 22 Nov 2012 05:25:14 -0800 (PST) In-Reply-To: <1353590706-1366-1-git-send-email-imre.deak@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org Signed-off-by: Imre Deak --- tests/flip_test.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) 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) -- 1.7.9.5