DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas.monjalon@6wind.com>
To: tomasz.kantecki@intel.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] app/test: remove useless clock estimation
Date: Wed,  6 Jul 2016 17:22:22 +0200	[thread overview]
Message-ID: <1467818542-30609-1-git-send-email-thomas.monjalon@6wind.com> (raw)

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 <thomas.monjalon@6wind.com>
---
 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

             reply	other threads:[~2016-07-06 15:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-06 15:22 Thomas Monjalon [this message]
2016-07-10 14:15 ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467818542-30609-1-git-send-email-thomas.monjalon@6wind.com \
    --to=thomas.monjalon@6wind.com \
    --cc=dev@dpdk.org \
    --cc=tomasz.kantecki@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).