From patchwork Thu Oct 15 13:02:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 55000 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lf0-f70.google.com (mail-lf0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id 287DD2301F for ; Thu, 15 Oct 2015 13:04:37 +0000 (UTC) Received: by lfbe131 with SMTP id e131sf2059182lfb.3 for ; Thu, 15 Oct 2015 06:04:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=DrgRGMb/R9AMKiB0rH11o2ZozwKTmq++AjRsySycWdM=; b=N6NL7dj7SbLwjiv4A/nomhp4FMzdmuIM834mLJNNla2QC9tLd3RlPLx9Dql8A1IJa4 QgfNAaidazyd21dRppye0pxExqW684drkpnaFKiGY6XBcGVwX8atbMYVMshmcg8pIyZN s7VyErEMCnvNtLcAn6X9Wse06MgjxBv8giOrfiKlYP1LJPLoqyxIFxguXPCWy32k8iZ4 ER+JYtBkwjB5dYyY6B3hH7tfh/ug1ZZ7FT5XQIaGIt1sa10ZiJ2zGGF/zhloAU/J1avu d1Y4bNHAGJ4sh2lso660bkvYP9P3CPzC3uOZl6CwBDQl9pmwkJqT7WuVEQCtKsWAX4TS dQUw== X-Gm-Message-State: ALoCoQkhllBKCCOjKPZpREY0PS/+79DEPZCCqSFg8D3PuRberEaeL0g8TEUu9eq1vtabIUbUHD7l X-Received: by 10.112.151.9 with SMTP id um9mr2116851lbb.19.1444914275898; Thu, 15 Oct 2015 06:04:35 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.153.9 with SMTP id b9ls144466lfe.85.gmail; Thu, 15 Oct 2015 06:04:35 -0700 (PDT) X-Received: by 10.25.206.199 with SMTP id e190mr2904625lfg.39.1444914275762; Thu, 15 Oct 2015 06:04:35 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id qi7si9096526lbb.13.2015.10.15.06.04.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Oct 2015 06:04:35 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbwr8 with SMTP id r8so68178655lbw.2 for ; Thu, 15 Oct 2015 06:04:35 -0700 (PDT) X-Received: by 10.112.132.7 with SMTP id oq7mr4580175lbb.32.1444914275495; Thu, 15 Oct 2015 06:04:35 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp620861lbq; Thu, 15 Oct 2015 06:04:34 -0700 (PDT) X-Received: by 10.140.41.232 with SMTP id z95mr2889687qgz.41.1444914274496; Thu, 15 Oct 2015 06:04:34 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 76si1573991qhx.105.2015.10.15.06.04.34; Thu, 15 Oct 2015 06:04:34 -0700 (PDT) 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; Received: by lists.linaro.org (Postfix, from userid 109) id EFA6261FD6; Thu, 15 Oct 2015 13:04:33 +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.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 7338461FDC; Thu, 15 Oct 2015 13:02:51 +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 060C661FDA; Thu, 15 Oct 2015 13:02:41 +0000 (UTC) Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com [209.85.212.174]) by lists.linaro.org (Postfix) with ESMTPS id 415EB61D94 for ; Thu, 15 Oct 2015 13:02:35 +0000 (UTC) Received: by wijp11 with SMTP id p11so28653713wij.0 for ; Thu, 15 Oct 2015 06:02:34 -0700 (PDT) X-Received: by 10.194.112.104 with SMTP id ip8mr12286820wjb.85.1444914154321; Thu, 15 Oct 2015 06:02:34 -0700 (PDT) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id z4sm11886602wjz.29.2015.10.15.06.02.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Oct 2015 06:02:33 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org, petri.savolainen@nokia.com Date: Thu, 15 Oct 2015 16:02:19 +0300 Message-Id: <1444914142-20587-3-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1444914142-20587-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1444914142-20587-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v4 2/5] 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: 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ivan.khoronzhuk@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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 5a0d5a4..47d28a6 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -585,7 +585,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; @@ -593,6 +593,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) { @@ -602,12 +603,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();