From patchwork Mon Nov 23 21:20:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 57202 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1685839lbb; Mon, 23 Nov 2015 13:25:05 -0800 (PST) X-Received: by 10.55.77.73 with SMTP id a70mr19002921qkb.106.1448313905228; Mon, 23 Nov 2015 13:25:05 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p104si2125876qgd.126.2015.11.23.13.25.04; Mon, 23 Nov 2015 13:25:05 -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 D619B61CF6; Mon, 23 Nov 2015 21:25:04 +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 8E9BA61D09; Mon, 23 Nov 2015 21:21:41 +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 CDBBB61CC5; Mon, 23 Nov 2015 21:21:36 +0000 (UTC) Received: from mail-lf0-f42.google.com (mail-lf0-f42.google.com [209.85.215.42]) by lists.linaro.org (Postfix) with ESMTPS id 23B9D61CC5 for ; Mon, 23 Nov 2015 21:21:08 +0000 (UTC) Received: by lfaz4 with SMTP id z4so120289120lfa.0 for ; Mon, 23 Nov 2015 13:21:07 -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=I/M5losz8FwhcW2nw5osSZGhO4e3DYXIMLld38o3+bo=; b=q+sIrIKWBuREWaZZiLhp6XgWmvtoO+BThdS0lX/msmPdlvQnG5bbcpEeNtA5xji3dg Psv1H7yd8l91Z8pEFgyci8y+GHcd5Ax5YjjmjaqyZrECwqKjWKm1moM1jislvpXxMTCV wL6Z3rE3++D39Ls4RkczkIFoT9ianDe33CD660saGOWoq2cQI5+5JRdf+agC2BH0ipwI wyFd9a7PtQKtjskKLCqx4gWeaTcZ/Te+z986/lN+no95KjxCl0aXraljT3LtrdvEdwA7 t2QeXOGTinFKNQQFcwg8ODCzygsEmhsJQ7wTCpSokt+NlXNGMQUXYH6VmbHdGCFebOl8 AfSQ== 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=I/M5losz8FwhcW2nw5osSZGhO4e3DYXIMLld38o3+bo=; b=G+OTK/hKsHVhxP5zXdOHu1woqOgqbKz3vFl2QyI+RJWMjycrntIfNw4dgObRByiFTf zZy+DgxL39huKk1Q9VqP/lOrGLAwvXaBLt4PoirDdrheKqgQTRGPVwmdEIYo1YroLjM7 6zX2ZBthBfVKCzdbPT2HRObL1saowIM0jSPbUi9pmZFj4EWV1v/mRKlc956SD9BoHpLu MjoFvhhA2B1bh6vU0LGzu12XsKKXZ08gi4v+PJLJSwdmxKn+inPo43XvHfz7+wRbLNoP pylC/CqTFfqz1gvXG0IudI5+HBf8JahNaTnLQIIswqgaf+Pu+FH2h3/bxySeI3Rx+0wW SWpg== X-Gm-Message-State: ALoCoQl0FbcGFStof8oiUftF8M9Dj89GJsj9GlFapVsYE0RH988eeRC7MwiCI5deb6tOMQRK9XeH X-Received: by 10.25.15.150 with SMTP id 22mr10163220lfp.19.1448313667016; Mon, 23 Nov 2015 13:21:07 -0800 (PST) Received: from localhost.localdomain ([212.90.60.8]) by smtp.gmail.com with ESMTPSA id r2sm2122027lfe.28.2015.11.23.13.21.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Nov 2015 13:21:06 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Mon, 23 Nov 2015 23:20:53 +0200 Message-Id: <1448313655-7949-6-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448313655-7949-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1448313655-7949-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v3 5/7] performance: sched: use ODP time API instead of clock_gettime 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" The time API can be used instead of Posix clock_gettime as more accurate and OS independent. Signed-off-by: Ivan Khoronzhuk --- test/performance/odp_scheduling.c | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c index 5d17c47..2c5262f 100644 --- a/test/performance/odp_scheduling.c +++ b/test/performance/odp_scheduling.c @@ -702,7 +702,7 @@ static void *run_thread(void *arg) */ static void test_cpu_freq(void) { - struct timespec tp1, tp2; + odp_time_t cur_time, test_time, start_time, end_time; uint64_t c1, c2, cycles; uint64_t nsec; double diff_max_hz, max_cycles; @@ -710,40 +710,21 @@ static void test_cpu_freq(void) printf("\nCPU cycle count frequency test (runs about %i sec)\n", TEST_SEC); - if (clock_gettime(CLOCK_MONOTONIC, &tp2)) { - LOG_ERR("clock_gettime failed.\n"); - return; - } - - /* Wait until clock moves to the next second. It enables easy comparison - * during the measurement. */ - do { - if (clock_gettime(CLOCK_MONOTONIC, &tp1)) { - LOG_ERR("clock_gettime failed.\n"); - return; - } - - } while (tp1.tv_sec == tp2.tv_sec); + test_time = odp_time_local_from_ns(TEST_SEC * ODP_TIME_SEC_IN_NS); + start_time = odp_time_local(); + end_time = odp_time_sum(start_time, test_time); /* Start the measurement */ c1 = odp_cpu_cycles(); do { - if (clock_gettime(CLOCK_MONOTONIC, &tp2)) { - LOG_ERR("clock_gettime failed.\n"); - return; - } - - } while ((tp2.tv_sec - tp1.tv_sec) < TEST_SEC); + cur_time = odp_time_local(); + } while (odp_time_cmp(end_time, cur_time) > 0); c2 = odp_cpu_cycles(); - nsec = (tp2.tv_sec - tp1.tv_sec) * 1000000000; - - if (tp2.tv_nsec > tp1.tv_nsec) - nsec += tp2.tv_nsec - tp1.tv_nsec; - else - nsec -= tp1.tv_nsec - tp2.tv_nsec; + test_time = odp_time_diff(cur_time, start_time); + nsec = odp_time_to_ns(test_time); cycles = odp_cpu_cycles_diff(c2, c1); max_cycles = (nsec * odp_cpu_hz_max()) / 1000000000.0; @@ -751,7 +732,7 @@ static void test_cpu_freq(void) /* Compare measured CPU cycles to maximum theoretical CPU cycle count */ diff_max_hz = ((double)(cycles) - max_cycles) / max_cycles; - printf("clock_gettime %" PRIu64 " ns\n", nsec); + printf("odp_time %" PRIu64 " ns\n", nsec); printf("odp_cpu_cycles %" PRIu64 " CPU cycles\n", cycles); printf("odp_sys_cpu_hz %" PRIu64 " hz\n", odp_cpu_hz_max()); printf("Diff from max CPU freq %f%%\n", diff_max_hz * 100.0);