[dpdk-dev] [PATCH v3 5/6] eal: add bounded PRNG performance tests

Mattias Rönnblom mattias.ronnblom at ericsson.com
Wed Jun 5 12:43:59 CEST 2019


Add best- and worst-case performance tests for rte_rand_max().

Signed-off-by: Mattias Rönnblom <mattias.ronnblom at ericsson.com>
Acked-by: Bruce Richardson <bruce.richardson at intel.com>
---
 app/test/test_rand_perf.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/app/test/test_rand_perf.c b/app/test/test_rand_perf.c
index 771713757..fe797ebfa 100644
--- a/app/test/test_rand_perf.c
+++ b/app/test/test_rand_perf.c
@@ -15,8 +15,13 @@ static volatile uint64_t vsum;
 
 #define ITERATIONS (100000000)
 
+#define BEST_CASE_BOUND (1<<16)
+#define WORST_CASE_BOUND (BEST_CASE_BOUND + 1)
+
 enum rand_type {
-	rand_type_64
+	rand_type_64,
+	rand_type_bounded_best_case,
+	rand_type_bounded_worst_case
 };
 
 static const char *
@@ -25,6 +30,10 @@ rand_type_desc(enum rand_type rand_type)
 	switch (rand_type) {
 	case rand_type_64:
 		return "Full 64-bit [rte_rand()]";
+	case rand_type_bounded_best_case:
+		return "Bounded average best-case [rte_rand_max()]";
+	case rand_type_bounded_worst_case:
+		return "Bounded average worst-case [rte_rand_max()]";
 	default:
 		return NULL;
 	}
@@ -46,6 +55,12 @@ test_rand_perf_type(enum rand_type rand_type)
 		case rand_type_64:
 			sum += rte_rand();
 			break;
+		case rand_type_bounded_best_case:
+			sum += rte_rand_max(BEST_CASE_BOUND);
+			break;
+		case rand_type_bounded_worst_case:
+			sum += rte_rand_max(WORST_CASE_BOUND);
+			break;
 		}
 	}
 
@@ -68,6 +83,8 @@ test_rand_perf(void)
 	printf("Pseudo-random number generation latencies:\n");
 
 	test_rand_perf_type(rand_type_64);
+	test_rand_perf_type(rand_type_bounded_best_case);
+	test_rand_perf_type(rand_type_bounded_worst_case);
 
 	return 0;
 }
-- 
2.17.1



More information about the dev mailing list