From: Pablo de Lara Date: Wed, 10 Jun 2015 15:25:19 +0000 (+0100) Subject: app/test: improve accuracy on hash measurements X-Git-Tag: spdx-start~9075 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=4072a35a87d71827c05605ae39eb93b07e9cfd49;p=dpdk.git app/test: improve accuracy on hash measurements 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 Acked-by: Bruce Richardson --- diff --git a/app/test/test_hash_functions.c b/app/test/test_hash_functions.c index 4efb3cd117..767b2bc14b 100644 --- a/app/test/test_hash_functions.c +++ b/app/test/test_hash_functions.c @@ -83,21 +83,21 @@ static void run_hash_func_perf_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); }