[dpdk-dev,v5,04/10] test/hash: change order of loops in hash function tests

Message ID 1432289771-12799-5-git-send-email-pablo.de.lara.guarch@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

De Lara Guarch, Pablo May 22, 2015, 10:16 a.m. UTC
  In order to see more clearly the performance difference
between different hash functions, order of the loops
have been changed, so it iterates first through initial values,
then key sizes and then the hash functions.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test/test_hash_functions.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
  

Comments

Bruce Richardson June 10, 2015, 11:05 a.m. UTC | #1
On Fri, May 22, 2015 at 11:16:05AM +0100, Pablo de Lara wrote:
> In order to see more clearly the performance difference
> between different hash functions, order of the loops
> have been changed, so it iterates first through initial values,
> then key sizes and then the hash functions.
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
>  app/test/test_hash_functions.c |   20 ++++++++++----------
>  1 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/app/test/test_hash_functions.c b/app/test/test_hash_functions.c
> index 973fbe8..3b72e8f 100644
> --- a/app/test/test_hash_functions.c
> +++ b/app/test/test_hash_functions.c
> @@ -86,8 +86,8 @@ get_hash_name(rte_hash_function f)
>   * Test a hash function.
>   */
>  static void
> -run_hash_func_perf_test(rte_hash_function f, uint32_t init_val,
> -		uint32_t key_len)
> +run_hash_func_perf_test(uint32_t key_len, uint32_t init_val,
> +		rte_hash_function f)
>  {
>  	static uint8_t key[HASHTEST_ITERATIONS][RTE_HASH_KEY_LENGTH_MAX];
>  	uint64_t ticks, start, end;
> @@ -122,17 +122,17 @@ run_hash_func_perf_tests(void)
>  	printf("Hash Func.  , Key Length (bytes), Initial value, Ticks/Op.\n");
>  
>  	for (i = 0;
> -	     i < sizeof(hashtest_funcs) / sizeof(rte_hash_function);
> +	     i < sizeof(hashtest_initvals) / sizeof(uint32_t);
>  	     i++) {
>  		for (j = 0;
> -		     j < sizeof(hashtest_initvals) / sizeof(uint32_t);
> -		     j++) {
> +		     j < sizeof(hashtest_key_lens) / sizeof(uint32_t);
> +	             j++) {
>  			for (k = 0;
> -			     k < sizeof(hashtest_key_lens) / sizeof(uint32_t);
> -			     k++) {

These for loops should be changed to use RTE_DIM() macro when possible. It should
allow each loop to just take up one line instead of three, as well as avoiding
changes to the loops if the type of value ever changes from uint32_t.

/Bruce
  

Patch

diff --git a/app/test/test_hash_functions.c b/app/test/test_hash_functions.c
index 973fbe8..3b72e8f 100644
--- a/app/test/test_hash_functions.c
+++ b/app/test/test_hash_functions.c
@@ -86,8 +86,8 @@  get_hash_name(rte_hash_function f)
  * Test a hash function.
  */
 static void
-run_hash_func_perf_test(rte_hash_function f, uint32_t init_val,
-		uint32_t key_len)
+run_hash_func_perf_test(uint32_t key_len, uint32_t init_val,
+		rte_hash_function f)
 {
 	static uint8_t key[HASHTEST_ITERATIONS][RTE_HASH_KEY_LENGTH_MAX];
 	uint64_t ticks, start, end;
@@ -122,17 +122,17 @@  run_hash_func_perf_tests(void)
 	printf("Hash Func.  , Key Length (bytes), Initial value, Ticks/Op.\n");
 
 	for (i = 0;
-	     i < sizeof(hashtest_funcs) / sizeof(rte_hash_function);
+	     i < sizeof(hashtest_initvals) / sizeof(uint32_t);
 	     i++) {
 		for (j = 0;
-		     j < sizeof(hashtest_initvals) / sizeof(uint32_t);
-		     j++) {
+		     j < sizeof(hashtest_key_lens) / sizeof(uint32_t);
+	             j++) {
 			for (k = 0;
-			     k < sizeof(hashtest_key_lens) / sizeof(uint32_t);
-			     k++) {
-				run_hash_func_perf_test(hashtest_funcs[i],
-						hashtest_initvals[j],
-						hashtest_key_lens[k]);
+		             k < sizeof(hashtest_funcs) / sizeof(rte_hash_function);
+		             k++) {
+				run_hash_func_perf_test(hashtest_key_lens[j],
+						hashtest_initvals[i],
+						hashtest_funcs[k]);
 			}
 		}
 	}