DPDK patches and discussions
 help / color / mirror / Atom feed
From: Pablo de Lara <pablo.de.lara.guarch@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v4 1/6] test/hash: move hash function perf tests to separate file
Date: Tue, 12 May 2015 12:02:33 +0100	[thread overview]
Message-ID: <1431428560-25426-2-git-send-email-pablo.de.lara.guarch@intel.com> (raw)
In-Reply-To: <1431428560-25426-1-git-send-email-pablo.de.lara.guarch@intel.com>

This patch moves hash function performance tests to a separate file,
so user can check performance of the existing hash functions quicker,
without having to run all the other hash operation performance tests,
which takes some time.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test/Makefile              |    1 +
 app/test/test_hash_func_perf.c |  145 ++++++++++++++++++++++++++++++++++++++++
 app/test/test_hash_perf.c      |   71 +-------------------
 3 files changed, 147 insertions(+), 70 deletions(-)
 create mode 100644 app/test/test_hash_func_perf.c

diff --git a/app/test/Makefile b/app/test/Makefile
index 4aca77c..77a9c42 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -83,6 +83,7 @@ SRCS-y += test_memcpy_perf.c
 
 SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash.c
 SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash_perf.c
+SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash_func_perf.c
 
 SRCS-$(CONFIG_RTE_LIBRTE_LPM) += test_lpm.c
 SRCS-$(CONFIG_RTE_LIBRTE_LPM) += test_lpm6.c
diff --git a/app/test/test_hash_func_perf.c b/app/test/test_hash_func_perf.c
new file mode 100644
index 0000000..ba31c53
--- /dev/null
+++ b/app/test/test_hash_func_perf.c
@@ -0,0 +1,145 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <errno.h>
+#include <sys/queue.h>
+
+#include <rte_cycles.h>
+#include <rte_random.h>
+
+#include "test.h"
+
+#include <rte_hash.h>
+#include <rte_jhash.h>
+#include <rte_hash_crc.h>
+
+/*******************************************************************************
+ * Hash function performance test configuration section. Each performance test
+ * will be performed HASHTEST_ITERATIONS times.
+ *
+ * The three arrays below control what tests are performed. Every combination
+ * from the array entries is tested.
+ */
+#define HASHTEST_ITERATIONS 1000000
+
+static rte_hash_function hashtest_funcs[] = {rte_jhash, rte_hash_crc};
+static uint32_t hashtest_initvals[] = {0};
+static uint32_t hashtest_key_lens[] = {2, 4, 5, 6, 7, 8, 10, 11, 15, 16, 21, 31, 32, 33, 63, 64};
+/******************************************************************************/
+
+/*
+ * To help print out name of hash functions.
+ */
+static const char *get_hash_name(rte_hash_function f)
+{
+	if (f == rte_jhash)
+		return "jhash";
+
+	if (f == rte_hash_crc)
+		return "rte_hash_crc";
+
+	return "UnknownHash";
+}
+
+/*
+ * Test a hash function.
+ */
+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;
+	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;
+	}
+
+	printf("%-12s, %-18u, %-13u, %.02f\n", get_hash_name(f), (unsigned) key_len,
+			(unsigned) init_val, (double)ticks / HASHTEST_ITERATIONS);
+}
+
+/*
+ * Test all hash functions.
+ */
+static void run_hash_func_tests(void)
+{
+	unsigned i, j, k;
+
+	printf(" *** Hash function performance test results ***\n");
+	printf(" Number of iterations for each test = %d\n",
+			HASHTEST_ITERATIONS);
+	printf("Hash Func.  , Key Length (bytes), Initial value, Ticks/Op.\n");
+
+	for (i = 0;
+	     i < sizeof(hashtest_funcs) / sizeof(rte_hash_function);
+	     i++) {
+		for (j = 0;
+		     j < sizeof(hashtest_initvals) / sizeof(uint32_t);
+		     j++) {
+			for (k = 0;
+			     k < sizeof(hashtest_key_lens) / sizeof(uint32_t);
+			     k++) {
+				run_hash_func_test(hashtest_funcs[i],
+						hashtest_initvals[j],
+						hashtest_key_lens[k]);
+			}
+		}
+	}
+}
+
+static int
+test_hash_func_perf(void)
+{
+	run_hash_func_tests();
+
+	return 0;
+}
+
+static struct test_command hash_func_perf_cmd = {
+	.command = "hash_func_perf_autotest",
+	.callback = test_hash_func_perf,
+};
+REGISTER_TEST_COMMAND(hash_func_perf_cmd);
diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c
index 6eabb21..d0e5ce0 100644
--- a/app/test/test_hash_perf.c
+++ b/app/test/test_hash_perf.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -85,20 +85,6 @@ struct tbl_perf_test_params {
 #define LOCAL_FBK_HASH_ENTRIES_MAX (1 << 15)
 
 /*******************************************************************************
- * Hash function performance test configuration section. Each performance test
- * will be performed HASHTEST_ITERATIONS times.
- *
- * The five arrays below control what tests are performed. Every combination
- * from the array entries is tested.
- */
-#define HASHTEST_ITERATIONS 1000000
-
-static rte_hash_function hashtest_funcs[] = {rte_jhash, rte_hash_crc};
-static uint32_t hashtest_initvals[] = {0};
-static uint32_t hashtest_key_lens[] = {2, 4, 5, 6, 7, 8, 10, 11, 15, 16, 21, 31, 32, 33, 63, 64};
-/******************************************************************************/
-
-/*******************************************************************************
  * Hash table performance test configuration section.
  */
 struct tbl_perf_test_params tbl_perf_params[] =
@@ -617,60 +603,6 @@ static int run_all_tbl_perf_tests(void)
 	return 0;
 }
 
-/*
- * Test a hash function.
- */
-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;
-	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;
-	}
-
-	printf("%-12s, %-18u, %-13u, %.02f\n", get_hash_name(f), (unsigned) key_len,
-			(unsigned) init_val, (double)ticks / HASHTEST_ITERATIONS);
-}
-
-/*
- * Test all hash functions.
- */
-static void run_hash_func_tests(void)
-{
-	unsigned i, j, k;
-
-	printf("\n\n *** Hash function performance test results ***\n");
-	printf(" Number of iterations for each test = %d\n",
-			HASHTEST_ITERATIONS);
-	printf("Hash Func.  , Key Length (bytes), Initial value, Ticks/Op.\n");
-
-	for (i = 0;
-	     i < sizeof(hashtest_funcs) / sizeof(rte_hash_function);
-	     i++) {
-		for (j = 0;
-		     j < sizeof(hashtest_initvals) / sizeof(uint32_t);
-		     j++) {
-			for (k = 0;
-			     k < sizeof(hashtest_key_lens) / sizeof(uint32_t);
-			     k++) {
-				run_hash_func_test(hashtest_funcs[i],
-						hashtest_initvals[j],
-						hashtest_key_lens[k]);
-			}
-		}
-	}
-}
-
 /* Control operation of performance testing of fbk hash. */
 #define LOAD_FACTOR 0.667	/* How full to make the hash table. */
 #define TEST_SIZE 1000000	/* How many operations to time. */
@@ -757,7 +689,6 @@ test_hash_perf(void)
 {
 	if (run_all_tbl_perf_tests() < 0)
 		return -1;
-	run_hash_func_tests();
 
 	if (fbk_hash_perf_test() < 0)
 		return -1;
-- 
1.7.4.1

  reply	other threads:[~2015-05-12 11:03 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-16 13:26 [dpdk-dev] [PATCH] hash: update jhash function with the latest available Pablo de Lara
2015-04-16 14:01 ` Bruce Richardson
2015-04-17 16:03   ` De Lara Guarch, Pablo
2015-04-24 11:23 ` [dpdk-dev] [PATCH v2 0/6] update jhash function Pablo de Lara
2015-04-24 11:23   ` [dpdk-dev] [PATCH v2 1/6] test/hash: move hash function perf tests to separate file Pablo de Lara
2015-04-24 11:23   ` [dpdk-dev] [PATCH v2 2/6] test/hash: improve accuracy on cycle measurements Pablo de Lara
2015-04-24 11:23   ` [dpdk-dev] [PATCH v2 3/6] hash: update jhash function with the latest available Pablo de Lara
2015-04-24 11:23   ` [dpdk-dev] [PATCH v2 4/6] hash: add two new functions to jhash library Pablo de Lara
2015-04-24 11:23   ` [dpdk-dev] [PATCH v2 5/6] hash: remove duplicated code Pablo de Lara
2015-04-24 11:23   ` [dpdk-dev] [PATCH v2 6/6] hash: rename rte_jhash2 to rte_jhash_32b Pablo de Lara
2015-05-05 14:43   ` [dpdk-dev] [PATCH v3 0/6] update jhash function Pablo de Lara
2015-05-05 14:43     ` [dpdk-dev] [PATCH v3 1/6] test/hash: move hash function perf tests to separate file Pablo de Lara
2015-05-05 14:43     ` [dpdk-dev] [PATCH v3 2/6] test/hash: improve accuracy on cycle measurements Pablo de Lara
2015-05-05 14:43     ` [dpdk-dev] [PATCH v3 3/6] hash: update jhash function with the latest available Pablo de Lara
2015-05-06  0:35       ` Ananyev, Konstantin
2015-05-06  9:36         ` De Lara Guarch, Pablo
2015-05-06 16:11           ` Ananyev, Konstantin
2015-05-07 11:11           ` Ananyev, Konstantin
2015-05-05 14:43     ` [dpdk-dev] [PATCH v3 4/6] hash: add two new functions to jhash library Pablo de Lara
2015-05-05 14:43     ` [dpdk-dev] [PATCH v3 5/6] hash: remove duplicated code Pablo de Lara
2015-05-05 14:43     ` [dpdk-dev] [PATCH v3 6/6] hash: rename rte_jhash2 to rte_jhash_32b Pablo de Lara
2015-05-12 11:02     ` [dpdk-dev] [PATCH v4 0/6] update jhash function Pablo de Lara
2015-05-12 11:02       ` Pablo de Lara [this message]
2015-05-12 11:02       ` [dpdk-dev] [PATCH v4 2/6] test/hash: improve accuracy on cycle measurements Pablo de Lara
2015-05-12 11:02       ` [dpdk-dev] [PATCH v4 3/6] hash: update jhash function with the latest available Pablo de Lara
2015-05-12 11:02       ` [dpdk-dev] [PATCH v4 4/6] hash: add two new functions to jhash library Pablo de Lara
2015-05-12 11:02       ` [dpdk-dev] [PATCH v4 5/6] hash: remove duplicated code Pablo de Lara
2015-05-12 11:02       ` [dpdk-dev] [PATCH v4 6/6] hash: rename rte_jhash2 to rte_jhash_32b Pablo de Lara
2015-05-12 15:33       ` [dpdk-dev] [PATCH v4 0/6] update jhash function Neil Horman
2015-05-13 13:52         ` De Lara Guarch, Pablo
2015-05-13 14:20           ` Neil Horman
2015-05-18 16:14       ` Bruce Richardson
2015-05-22 10:16       ` [dpdk-dev] [PATCH v5 00/10] " Pablo de Lara
2015-05-22 10:16         ` [dpdk-dev] [PATCH v5 01/10] test/hash: move hash function perf tests to separate file Pablo de Lara
2015-05-22 10:16         ` [dpdk-dev] [PATCH v5 02/10] test/hash: improve accuracy on cycle measurements Pablo de Lara
2015-05-22 10:16         ` [dpdk-dev] [PATCH v5 03/10] test/hash: update key size range and initial values for testing Pablo de Lara
2015-05-22 10:16         ` [dpdk-dev] [PATCH v5 04/10] test/hash: change order of loops in hash function tests Pablo de Lara
2015-06-10 11:05           ` Bruce Richardson
2015-05-22 10:16         ` [dpdk-dev] [PATCH v5 05/10] test/hash: add new functional tests for hash functions Pablo de Lara
2015-05-22 10:16         ` [dpdk-dev] [PATCH v5 06/10] hash: update jhash function with the latest available Pablo de Lara
2015-06-10 11:07           ` Bruce Richardson
2015-05-22 10:16         ` [dpdk-dev] [PATCH v5 07/10] hash: add two new functions to jhash library Pablo de Lara
2015-05-22 10:16         ` [dpdk-dev] [PATCH v5 08/10] hash: remove duplicated code Pablo de Lara
2015-05-22 10:16         ` [dpdk-dev] [PATCH v5 09/10] hash: rename rte_jhash2 to rte_jhash_32b Pablo de Lara
2015-06-10 11:09           ` Bruce Richardson
2015-05-22 10:16         ` [dpdk-dev] [PATCH v5 10/10] test/hash: verify rte_jhash_1word/2words/3words Pablo de Lara
2015-06-10 15:25         ` [dpdk-dev] [PATCH v6 00/10] update jhash function Pablo de Lara
2015-06-10 15:25           ` [dpdk-dev] [PATCH v6 01/10] test/hash: move hash function perf tests to separate file Pablo de Lara
2015-06-10 15:25           ` [dpdk-dev] [PATCH v6 02/10] test/hash: improve accuracy on cycle measurements Pablo de Lara
2015-06-10 15:25           ` [dpdk-dev] [PATCH v6 03/10] test/hash: update key size range and initial values for testing Pablo de Lara
2015-06-10 15:25           ` [dpdk-dev] [PATCH v6 04/10] test/hash: change order of loops in hash function tests Pablo de Lara
2015-06-10 15:25           ` [dpdk-dev] [PATCH v6 05/10] test/hash: add new functional tests for hash functions Pablo de Lara
2015-06-10 15:25           ` [dpdk-dev] [PATCH v6 06/10] hash: update jhash function with the latest available Pablo de Lara
2015-06-10 15:25           ` [dpdk-dev] [PATCH v6 07/10] hash: add two new functions to jhash library Pablo de Lara
2015-06-10 15:25           ` [dpdk-dev] [PATCH v6 08/10] hash: remove duplicated code Pablo de Lara
2015-06-16  9:33             ` Thomas Monjalon
2015-06-16 10:31               ` De Lara Guarch, Pablo
2015-06-16 13:08                 ` Thomas Monjalon
2015-06-10 15:25           ` [dpdk-dev] [PATCH v6 09/10] hash: rename rte_jhash2 to rte_jhash_32b Pablo de Lara
2015-06-10 15:25           ` [dpdk-dev] [PATCH v6 10/10] test/hash: verify rte_jhash_1word/2words/3words Pablo de Lara
2015-06-12 10:37           ` [dpdk-dev] [PATCH v6 00/10] update jhash function Bruce Richardson
2015-06-16 10:22             ` 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=1431428560-25426-2-git-send-email-pablo.de.lara.guarch@intel.com \
    --to=pablo.de.lara.guarch@intel.com \
    --cc=dev@dpdk.org \
    /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).