From: Christopher Dykes Date: Fri, 14 Jul 2017 18:07:28 +0000 (-0700) Subject: Add an sfmt19937 benchmark (again) X-Git-Tag: v2017.07.17.00~5 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=112ec1357b9a05be29973ccab46a1487d886d18e;p=folly.git Add an sfmt19937 benchmark (again) Summary: `__gnu_cxx::sfmt19937` is 3.5x faster than `std::mt19937` according to the benchmark. Reviewed By: yfeldblum Differential Revision: D5410705 fbshipit-source-id: d503544a0b9b1b0c614a27466a297a4e6902fc15 --- diff --git a/folly/test/RandomBenchmark.cpp b/folly/test/RandomBenchmark.cpp index 60f6c5bc..bd793aed 100644 --- a/folly/test/RandomBenchmark.cpp +++ b/folly/test/RandomBenchmark.cpp @@ -24,6 +24,10 @@ #include #include +#if FOLLY_HAVE_EXTRANDOM_SFMT19937 +#include +#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;