From patchwork Thu Oct 22 12:01:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 55436 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id E9B1522AA5 for ; Thu, 22 Oct 2015 12:03:18 +0000 (UTC) Received: by wiclg3 with SMTP id lg3sf33011234wic.3 for ; Thu, 22 Oct 2015 05:03:18 -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=3+In2H6+7wOnNZQwgFSPtX6qAjuOaY0SWKnmMzLbymM=; b=aKtzwSoIeg24hqZJs9jWPbPeOtgr5c/1+MdTO7woELdhTc0HCV2cLR3EhrfzrC5DL3 NZPc/Qn2ZmeBUBGii876KX7wzBdhy0FHxlRQiCuGgPMCBijbtiV7bdi6DExnUbBcDRCm eqtZA4b/YF+8x51mLi6GWaXSibMlPXYSaY7Z6mkk6UrNeiY3H2UyB1Q3FEeEmITKXJv3 6MQigRnOrMDdxv4Vv2cDjZCGjUCMLq2s9BxRhZdDL4zCs8LihcM52M4JUSLUKezb2BB4 hZGWdAE9wuU6yi89TSqCZIC+2lyXYb0dIikZOwO9QLE65AfPyUxskj+HiBopDOIOk68s 8LeQ== X-Gm-Message-State: ALoCoQmsrZpJYOw+pg7S/9I8JPRpw9E0xZySkAZ6qalJLb6Z8lD4GDrCeIxie/ix6WqBMwyrz0cq X-Received: by 10.112.209.73 with SMTP id mk9mr3569621lbc.14.1445515398203; Thu, 22 Oct 2015 05:03:18 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.33.196 with SMTP id h187ls340806lfh.4.gmail; Thu, 22 Oct 2015 05:03:18 -0700 (PDT) X-Received: by 10.112.12.3 with SMTP id u3mr6859511lbb.30.1445515398063; Thu, 22 Oct 2015 05:03:18 -0700 (PDT) Received: from mail-lf0-f43.google.com (mail-lf0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id p72si9389599lfp.112.2015.10.22.05.03.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Oct 2015 05:03:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by lfaz124 with SMTP id z124so45018025lfa.1 for ; Thu, 22 Oct 2015 05:03:18 -0700 (PDT) X-Received: by 10.112.146.104 with SMTP id tb8mr8327090lbb.35.1445515397946; Thu, 22 Oct 2015 05:03:17 -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 w3csp559731lbq; Thu, 22 Oct 2015 05:03:17 -0700 (PDT) X-Received: by 10.55.198.152 with SMTP id s24mr17853282qkl.1.1445515395331; Thu, 22 Oct 2015 05:03:15 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f18si933528qgd.56.2015.10.22.05.03.15; Thu, 22 Oct 2015 05:03:15 -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 ED54161D1D; Thu, 22 Oct 2015 12:03:14 +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 7680661D24; Thu, 22 Oct 2015 12:02:15 +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 B867E61CCC; Thu, 22 Oct 2015 12:02:11 +0000 (UTC) Received: from mail-lf0-f52.google.com (mail-lf0-f52.google.com [209.85.215.52]) by lists.linaro.org (Postfix) with ESMTPS id 8D46C61CD4 for ; Thu, 22 Oct 2015 12:01:50 +0000 (UTC) Received: by lffv3 with SMTP id v3so44945354lff.0 for ; Thu, 22 Oct 2015 05:01:49 -0700 (PDT) X-Received: by 10.112.62.194 with SMTP id a2mr8333123lbs.80.1445515309438; Thu, 22 Oct 2015 05:01:49 -0700 (PDT) Received: from khorivan.synapse.com ([212.90.60.8]) by smtp.gmail.com with ESMTPSA id bn5sm2296353lbc.16.2015.10.22.05.01.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Oct 2015 05:01:48 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org, petri.savolainen@nokia.com Date: Thu, 22 Oct 2015 15:01:36 +0300 Message-Id: <1445515299-18496-3-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445515299-18496-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1445515299-18496-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v5 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.215.43 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 f80104c..be9597b 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();