Add an sfmt19937 benchmark (again)
[folly.git] / folly / test / RandomBenchmark.cpp
index 60f6c5bc2e2e9cf0c511c857915f2dc4b6d62be9..bd793aedb44b357dba858cfa2b10a8573021c9de 100644 (file)
 #include <folly/Benchmark.h>
 #include <folly/Foreach.h>
 
+#if FOLLY_HAVE_EXTRANDOM_SFMT19937
+#include <ext/random>
+#endif
+
 using namespace folly;
 
 BENCHMARK(minstdrand, n) {
@@ -46,6 +50,18 @@ BENCHMARK(mt19937, n) {
   FOR_EACH_RANGE(i, 0, n) { doNotOptimizeAway(rng()); }
 }
 
+#if FOLLY_HAVE_EXTRANDOM_SFMT19937
+BENCHMARK(sfmt19937, n) {
+  BenchmarkSuspender braces;
+  std::random_device rd;
+  __gnu_cxx::sfmt19937 rng(rd());
+
+  braces.dismiss();
+
+  FOR_EACH_RANGE(i, 0, n) { doNotOptimizeAway(rng()); }
+}
+#endif
+
 BENCHMARK(threadprng, n) {
   BenchmarkSuspender braces;
   ThreadLocalPRNG tprng;