From patchwork Thu Nov 5 15:33:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 56062 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp475647lbr; Thu, 5 Nov 2015 07:35:39 -0800 (PST) X-Received: by 10.140.146.13 with SMTP id 13mr8478441qhs.1.1446737739777; Thu, 05 Nov 2015 07:35:39 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 190si1821410qhp.5.2015.11.05.07.35.39; Thu, 05 Nov 2015 07:35:39 -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 5948661B3F; Thu, 5 Nov 2015 15:35:39 +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 BEFA161AF3; Thu, 5 Nov 2015 15:34:17 +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 1995461A30; Thu, 5 Nov 2015 15:34:10 +0000 (UTC) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com [209.85.217.174]) by lists.linaro.org (Postfix) with ESMTPS id 2F73C61988 for ; Thu, 5 Nov 2015 15:34:05 +0000 (UTC) Received: by lbbwb3 with SMTP id wb3so38037528lbb.1 for ; Thu, 05 Nov 2015 07:34:04 -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=LOjiZ8rQ/GtET2QKdoNTTWWlCycuyQ9bDVRUKThPe1zJIscKXka0csgX6GxuLP4JOz eDDYH63QeXoKEbX/6DtdhRjFMUNfGpkntDLUN9PDRItIS+GrLIuQ4SFzDES6KtNk8uG7 mojEc/Be5iwDF0Ag09LzdLJyTIB7JaV46368D9KCQYm4o1x3mgTzMmecDbr7x1nTkRZY MTG7GnVVjjWudtAWqmy26dJz9rg31fOOJ8bGuv8QzT0SeiQdi7ncI88IbjW3mDz6wJ/H H0Dj9fEdeBVgQPjBezsPXlAQSaLKwCEmSinPuso+loVfglDG541JYm6NRl+A14PaGCjy 0E6g== 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=gimuuqICuODk7hE8mYcfXeXpk9psHPs7zptm/PiJb7+at1bdxMfP3txqwtf6SaMjUp AXvpqF0thHy0+RlYX1SKsowy/xT7nEObbdP6F2eTtpV+IsmLPo0uXf++wrGqc7kwDnm2 wS5jc9IHZwNhRk/lDl2qZSzp24A2/n/jy7vmlKv2xze/k5UKim+NpKPXp04MJWTDDaxF koTGf9iaXjZFqQ+3r8N9wQ96cmY+mNi6BD6rBqm+eiEq6O+eAp2eX1CZKIGPPIVWj6dj fif+L0B9gbY9adxcvzCIfaoDK0eLzJKjh8AldtM3PPDuBqJDX7nlWb4mT26pZ4HiddgY qARA== X-Gm-Message-State: ALoCoQlDeMq2V2RoAmDeUazIn8hnxggkSzUbdqXLdhj+emC79Yoo8FGvkjuHkbltotFO2/SkXGa7 X-Received: by 10.112.156.2 with SMTP id wa2mr4151926lbb.39.1446737644044; Thu, 05 Nov 2015 07:34:04 -0800 (PST) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id oi5sm1034061lbb.13.2015.11.05.07.34.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Nov 2015 07:34:02 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Thu, 5 Nov 2015 17:33:46 +0200 Message-Id: <1446737630-2323-3-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446737630-2323-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1446737630-2323-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v7 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();