From patchwork Tue Dec 1 15:08:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 57506 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp2239825lbb; Tue, 1 Dec 2015 07:16:01 -0800 (PST) X-Received: by 10.140.163.198 with SMTP id j189mr4353633qhj.36.1448982958813; Tue, 01 Dec 2015 07:15:58 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id y63si50577686qka.95.2015.12.01.07.15.58; Tue, 01 Dec 2015 07:15:58 -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 5F7A061E97; Tue, 1 Dec 2015 15:15:58 +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 29A8361E6B; Tue, 1 Dec 2015 15:11:40 +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 7CD9361E70; Tue, 1 Dec 2015 15:11:29 +0000 (UTC) Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by lists.linaro.org (Postfix) with ESMTPS id 7130961E70 for ; Tue, 1 Dec 2015 15:08:27 +0000 (UTC) Received: by lffu14 with SMTP id u14so12104676lff.1 for ; Tue, 01 Dec 2015 07:08:26 -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=em4AQ6Dsz9OOFI+SnAQI67vCcARCnnpxvP4lpqIjQiKD1VjMdaKKntmRKo930cyuev xraQjJOtnqHP5ehdWu8/dFIq+OP8vzCTnVmnGtbfsOFbDEk+bpyge3FyFa2g59zApZjk Cvp7bzR8ZPltmkIVDbBmuBWvcvK+2NtunjCRqt+E2rpjjfxEwhkuSpa7jpWlD3qkmpZe 7gLR5BOK5IJvsXSW0ZSOmjQXA+HOzTbZW2kWmXbain5JutpMdEVen6RgPI1zvipzh/+n 8thoz2wK1KRxFi7hjgk80FfQGQnziuq6yATu738c3FhwR4sGnGYFkq4KOYFmQPKCvRoR 3cMw== 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=Geql5SicVq261pwZspnTdWaWahn7jBii9wco7Qp1aCfZIyOYoVi0ag88Z+Gs0pzYMY KPKir68GZYgsY7vywtUFrpHbLa183EoYTrWS6FkQBNhgK9z+6be590+pOFEweSvsLutS F54mskHU/b8rFzwm/AVVHLQykiDqLkdQJnoqpbFTH3d7WKGLVsYoYjxhKSDG+GUjOpfM qMDhMafrmfnOhHrMePCROAns1ZT660BAtVLKRAJUvDPzdEablGTR8LeBx0bNoXcuU+yp A59MOKxxt0BZvX1e0UMP+CVonnBU9i+lMFPqmMxTxfvWrmrD2QfW0+jtTq+3N/wOp+/b RgYQ== X-Gm-Message-State: ALoCoQm/MRMeIG8nLPC6YN7pux+Er5UA+7TGlTxi1NmTo3EqUSH7SNvN+7WG8Nolp5BlKqR6l8Tw X-Received: by 10.112.200.138 with SMTP id js10mr22313830lbc.48.1448982506285; Tue, 01 Dec 2015 07:08:26 -0800 (PST) Received: from localhost.localdomain ([212.90.60.8]) by smtp.gmail.com with ESMTPSA id i194sm8278535lfg.20.2015.12.01.07.08.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Dec 2015 07:08:25 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Tue, 1 Dec 2015 17:08:09 +0200 Message-Id: <1448982493-8236-6-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448982493-8236-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1448982493-8236-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v5 5/9] 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);