From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 76F105A49 for ; Fri, 22 May 2015 12:16:17 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 22 May 2015 03:16:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,474,1427785200"; d="scan'208";a="575361280" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga003.jf.intel.com with ESMTP; 22 May 2015 03:16:15 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t4MAGDuh008095; Fri, 22 May 2015 11:16:13 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id t4MAGDMq013068; Fri, 22 May 2015 11:16:13 +0100 Received: (from pdelarax@localhost) by sivswdev02.ir.intel.com with id t4MAGDlW013064; Fri, 22 May 2015 11:16:13 +0100 From: Pablo de Lara To: dev@dpdk.org Date: Fri, 22 May 2015 11:16:03 +0100 Message-Id: <1432289771-12799-3-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1432289771-12799-1-git-send-email-pablo.de.lara.guarch@intel.com> References: <1431428560-25426-1-git-send-email-pablo.de.lara.guarch@intel.com> <1432289771-12799-1-git-send-email-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v5 02/10] test/hash: improve accuracy on cycle measurements 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: Fri, 22 May 2015 10:16:18 -0000 From: De Lara Guarch, Pablo 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_functions.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/test/test_hash_functions.c b/app/test/test_hash_functions.c index 4efb3cd..767b2bc 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); } -- 1.7.4.1