[5/6] eal: add bounded PRNG performance tests
Checks
Commit Message
Add best- and worst-case performance tests for rte_rand_max().
Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
---
app/test/test_rand_perf.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
@@ -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;
}