From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pablo de Lara Subject: [PATCH v2 2/6] test/hash: improve accuracy on cycle measurements Date: Fri, 24 Apr 2015 12:23:03 +0100 Message-ID: <1429874587-17939-3-git-send-email-pablo.de.lara.guarch@intel.com> References: <1429190819-27402-1-git-send-email-pablo.de.lara.guarch@intel.com> <1429874587-17939-1-git-send-email-pablo.de.lara.guarch@intel.com> To: dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: <1429874587-17939-1-git-send-email-pablo.de.lara.guarch-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" Cycles per hash calculation were measured per single operation. It is much more accurate to run several iterations between measurements and divide by number of iterations. Signed-off-by: Pablo de Lara --- app/test/test_hash_func_perf.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/test/test_hash_func_perf.c b/app/test/test_hash_func_perf.c index ba31c53..004c9be 100644 --- a/app/test/test_hash_func_perf.c +++ b/app/test/test_hash_func_perf.c @@ -82,21 +82,21 @@ static const char *get_hash_name(rte_hash_function f) static void run_hash_func_test(rte_hash_function f, uint32_t init_val, uint32_t key_len) { - static uint8_t key[RTE_HASH_KEY_LENGTH_MAX]; - uint64_t ticks = 0, start, end; + static uint8_t key[HASHTEST_ITERATIONS][RTE_HASH_KEY_LENGTH_MAX]; + uint64_t ticks, start, end; unsigned i, j; for (i = 0; i < HASHTEST_ITERATIONS; i++) { - for (j = 0; j < key_len; j++) - key[j] = (uint8_t) rte_rand(); - - start = rte_rdtsc(); - f(key, key_len, init_val); - end = rte_rdtsc(); - ticks += end - start; + key[i][j] = (uint8_t) rte_rand(); } + start = rte_rdtsc(); + for (i = 0; i < HASHTEST_ITERATIONS; i++) + f(key[i], key_len, init_val); + end = rte_rdtsc(); + ticks = end - start; + printf("%-12s, %-18u, %-13u, %.02f\n", get_hash_name(f), (unsigned) key_len, (unsigned) init_val, (double)ticks / HASHTEST_ITERATIONS); } -- 1.7.4.1