From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by dpdk.org (Postfix) with ESMTP id 3D7906CCF for ; Wed, 6 Jul 2016 17:22:52 +0200 (CEST) Received: by mail-wm0-f42.google.com with SMTP id 187so33070863wmz.1 for ; Wed, 06 Jul 2016 08:22:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=UeiEZ/N1gYWNOSH8jsVxYDupWi4Dm2fdCHhrItUgGlo=; b=EXnqXHHZQRCt+2xYyKJDR8BT3LJdV8SiCbN2mt5qsbqzCj/WcyP/a2uA4YYT94M1Fh l55gR2rrrgcgdgVmNpOB+FebdZ4uAH2OtqkQctzOSba9hhFlp8qLEbKo9Afa6hwp8SyR wEhkKQbipzsRBHjBN9l/WwirLSaEi9N9hVBmMjFtRtGahyQpVi6Qq7T3GCEz+eofSgxs wMfAcHRi74EgtBgBlSnkQH4y/TBvrktaxAfyhbd/jwOaQADyTIYd7Zl7QfexkBF7jrH2 daDCkSaAq0bRsjBTS3TJHjrn2suLMcuM0T5wdvmQr7a+rUIl3KI9V3Bk1YzrS+2dm/Sk wcng== 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; bh=UeiEZ/N1gYWNOSH8jsVxYDupWi4Dm2fdCHhrItUgGlo=; b=ELZHxlbEJS5B8l2jLPXsCbe50Nwx/M4TceC3ZyAyBr0fDTkyvSnVtppjGbWMhPUrCf 0YUv+wv3ikxT4aMUKeNNkEkM5NYTHZT8a6M2RwV1esXAUP7ExG2iCYNTDyZZgI0Ea659 4Rtqg9TZVULfSw6r61mbU71JSuHlhceVQuBSoksEK0EAYMWKiiNqUviUycsk/RwlQJ2V YynMAc93e8AmN7ibS6mxscZYgDPt/MtMHB1TFKSzFpyRTjTln0OimdiKb+kGXfKKHMyf emMx5H6fVvhoi9OVcOcbZ1a3ckg4DCXlFKWDi6AoCZ3vjLEQ1wx+nkOih8U4Pgu3qC99 LXwQ== X-Gm-Message-State: ALyK8tLzocXXQ/8PamVkBAZWEVo6mCNtVAuEj+CIrOlFw5oYy7kvrX0ro7eikoglsOXfWlrx X-Received: by 10.28.9.213 with SMTP id 204mr22940950wmj.88.1467818571984; Wed, 06 Jul 2016 08:22:51 -0700 (PDT) Received: from XPS13.localdomain (184.203.134.77.rev.sfr.net. [77.134.203.184]) by smtp.gmail.com with ESMTPSA id s67sm2794189wmf.3.2016.07.06.08.22.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Jul 2016 08:22:51 -0700 (PDT) From: Thomas Monjalon To: tomasz.kantecki@intel.com Cc: dev@dpdk.org Date: Wed, 6 Jul 2016 17:22:22 +0200 Message-Id: <1467818542-30609-1-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 2.7.0 Subject: [dpdk-dev] [PATCH] app/test: remove useless clock estimation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jul 2016 15:22:52 -0000 The function get_machclk_freq() in RED test can be replaced by rte_get_timer_hz() which already estimates the clock frequency at EAL init. Signed-off-by: Thomas Monjalon --- app/test/test_red.c | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/app/test/test_red.c b/app/test/test_red.c index 2384c55..7d1c32c 100644 --- a/app/test/test_red.c +++ b/app/test/test_red.c @@ -274,46 +274,6 @@ static int check_avg(double *diff, double avg, double exp_avg, double tolerance) } /** - * get the clk frequency in Hz - */ -static uint64_t get_machclk_freq(void) -{ - uint64_t start = 0; - uint64_t end = 0; - uint64_t diff = 0; - static uint64_t clk_freq_hz; - struct timespec tv_start = {0, 0}, tv_end = {0, 0}; - struct timespec req = {0, 0}; - - if (clk_freq_hz != 0) - return clk_freq_hz; - - req.tv_sec = 0; - req.tv_nsec = NSEC_PER_SEC / 4; - - clock_gettime(CLOCK_REALTIME, &tv_start); - start = rte_rdtsc(); - - if (nanosleep(&req, NULL) != 0) { - perror("get_machclk_freq()"); - exit(EXIT_FAILURE); - } - - clock_gettime(CLOCK_REALTIME, &tv_end); - end = rte_rdtsc(); - - diff = (uint64_t)(tv_end.tv_sec - tv_start.tv_sec) * USEC_PER_SEC - + ((tv_end.tv_nsec - tv_start.tv_nsec + TEST_NSEC_MARGIN) / - USEC_PER_MSEC); /**< diff is in micro secs */ - - if (diff == 0) - return 0; - - clk_freq_hz = ((end - start) * USEC_PER_SEC / diff); - return clk_freq_hz; -} - -/** * initialize the test rte_red config */ static enum test_result @@ -321,7 +281,7 @@ test_rte_red_init(struct test_config *tcfg) { unsigned i = 0; - tcfg->tvar->clk_freq = get_machclk_freq(); + tcfg->tvar->clk_freq = rte_get_timer_hz(); init_port_ts( tcfg->tvar->clk_freq ); for (i = 0; i < tcfg->tconfig->num_cfg; i++) { -- 2.7.0