From: Christopher Dykes Date: Tue, 11 Jul 2017 20:45:18 +0000 (-0700) Subject: Add an sfmt19937 benchmark X-Git-Tag: v2017.07.17.00~23 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=4169222e2f6da6ab300df01df71a46e6a1c38eac;p=folly.git Add an sfmt19937 benchmark Summary: `__gnu_cxx::sfmt19937` is 3.5x faster than `std::mt19937` according to the benchmark. Reviewed By: yfeldblum Differential Revision: D5393697 fbshipit-source-id: bc725838dc7f62d030c7e68bc6d229042df2b46c --- diff --git a/folly/test/RandomBenchmark.cpp b/folly/test/RandomBenchmark.cpp index 287482e5..b0991f17 100644 --- a/folly/test/RandomBenchmark.cpp +++ b/folly/test/RandomBenchmark.cpp @@ -46,6 +46,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;