#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 *
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;
}
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;
}
}
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;
}