From patchwork Thu Nov 5 11:04:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 56035 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp337358lbr; Thu, 5 Nov 2015 03:07:26 -0800 (PST) X-Received: by 10.140.167.69 with SMTP id n66mr6745304qhn.41.1446721646739; Thu, 05 Nov 2015 03:07:26 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id y69si4067588qka.73.2015.11.05.03.07.26; Thu, 05 Nov 2015 03:07:26 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: by lists.linaro.org (Postfix, from userid 109) id 5A07F61A0D; Thu, 5 Nov 2015 11:07:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 969A161B1E; Thu, 5 Nov 2015 11:06:27 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 0EFB1619C3; Thu, 5 Nov 2015 11:06:01 +0000 (UTC) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by lists.linaro.org (Postfix) with ESMTPS id 345B961B60 for ; Thu, 5 Nov 2015 11:04:51 +0000 (UTC) Received: by lbblt2 with SMTP id lt2so13674451lbb.3 for ; Thu, 05 Nov 2015 03:04:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ynAS4iIHo0cK2mU1L46Oxza3Jv4enSKvUEYLVBXX9Ww=; b=Mi1X1r9W6HlYHMYxXVrGrA3AL7owwJfftDlqXsmStep94aYQl0xQFm+che+BjCC8Lf am+8pdap+UnDM95q30/F7BKl941Mx8OTXPa+SSRVqQTvWYm44mvBII+80SZ6jN3rMJXT aw5si6w7sHGgfduViJEtATtbrptrJ/6JD2fJ/otNwIfvZM9UaiH+mqxacFO9hHHnKnma 8BHN5ngPn2ENJpUIVeC3AFlFXVz4j91ewPDYuZavdm04ZMQyPpCwMwD83Hci+TBBL7I0 Yizql4uj2zQCT6vKSl8PMT3gogwmHyjlFwiUDZlf2tqB5dsj/CEBuQpYRfCIbwMvsABz Ugug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ynAS4iIHo0cK2mU1L46Oxza3Jv4enSKvUEYLVBXX9Ww=; b=I6+rLtTiJnv7WldW2iQLnI08B98rxUmrdwJoJ8e0HR9pXIJx86Sq4Off4sPr3x4t8C TQ22o5Ta9RxaTrpXeTcKYKzac3paSkCII6MvaVgoJJXW7tOGh07KOpnjPLi/oLk1++tW YvdYGUJOfN/xIJJspLVz1ATaNhpR7WENc9IP+5dthPcPbxraAD0FWtKYzwJN6FMtbCOG Xs5+FWIL+jciOwyQ74bbqdb2rpnhNXgLSCopFIXFNyGtjJulbJVDlNwTTO63eBAMqMay Fv7GGze3b5g4Pw2M263e2lFeFVVVAa1+JzKvb8gR6m1KO+0MlgbZAXSsPRjEJav1+UmM /VMg== X-Gm-Message-State: ALoCoQlNk2+gn66MCsIowJ8mWkC020A3MuLrx4s3mna0jt8ozB2aZXSOJpZni2dC9QW2LLZDGknv X-Received: by 10.112.156.2 with SMTP id wa2mr3467177lbb.39.1446721489965; Thu, 05 Nov 2015 03:04:49 -0800 (PST) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id xk9sm868550lbb.23.2015.11.05.03.04.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Nov 2015 03:04:49 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Thu, 5 Nov 2015 13:04:34 +0200 Message-Id: <1446721478-30656-3-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446721478-30656-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1446721478-30656-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v6 2/6] example: generator: compare ticks instead of ns in loop X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" It's more accurate to compare ticks instead of ns in each iteration, so calculate wait range before entering the loop. Signed-off-by: Ivan Khoronzhuk --- example/generator/odp_generator.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 60e015b..dd30403 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -586,7 +586,7 @@ static void *gen_recv_thread(void *arg) */ static void print_global_stats(int num_workers) { - uint64_t start, now, diff; + uint64_t start, wait, diff; uint64_t pkts, pkts_prev = 0, pps, maximum_pps = 0; int verbose_interval = 20; odp_thrmask_t thrd_mask; @@ -594,6 +594,7 @@ static void print_global_stats(int num_workers) while (odp_thrmask_worker(&thrd_mask) < num_workers) continue; + wait = odp_time_ns_to_cycles(verbose_interval * ODP_TIME_SEC); start = odp_time_cycles(); while (odp_thrmask_worker(&thrd_mask) == num_workers) { @@ -603,12 +604,9 @@ static void print_global_stats(int num_workers) break; } - now = odp_time_cycles(); - diff = odp_time_diff_cycles(start, now); - if (odp_time_cycles_to_ns(diff) < - verbose_interval * ODP_TIME_SEC) { + diff = odp_time_diff_cycles(start, odp_time_cycles()); + if (diff < wait) continue; - } start = odp_time_cycles();