From patchwork Thu Nov 22 13:25:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 1783811 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id A840EDF230 for ; Thu, 22 Nov 2012 13:28:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8B0C8E5EB6 for ; Thu, 22 Nov 2012 05:28:41 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org 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) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 22 Nov 2012 05:25:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.83,300,1352102400"; d="scan'208";a="221085850" Received: from ideak-desk.fi.intel.com (HELO localhost) ([10.237.72.159]) by azsmga001.ch.intel.com with ESMTP; 22 Nov 2012 05:25:13 -0800 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 22 Nov 2012 15:25:05 +0200 Message-Id: <1353590706-1366-4-git-send-email-imre.deak@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1353590706-1366-1-git-send-email-imre.deak@intel.com> References: <1353590706-1366-1-git-send-email-imre.deak@intel.com> Subject: [Intel-gfx] [i-g-t PATCH 3/4] flip_test: use monotonic time to measure the test duration X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@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)