Shift monotonic_coarse_clock into Chrono.h and rename it to coarse_steady_clock
[folly.git] / folly / test / BitsBenchmark.cpp
index 8084a8b62d7a55ae1689be1a8a107fca576e690f..da0cab43c07e2105486cf5fa0b9e89eda895e6f6 100644 (file)
@@ -16,7 +16,7 @@
 
 // @author Tudor Bosman (tudorb@fb.com)
 
-#include <folly/Bits.h>
+#include <folly/lang/Bits.h>
 
 #include <folly/Benchmark.h>
 
@@ -38,6 +38,15 @@ BENCHMARK(isPowTwo, iters) {
   }
 }
 
+BENCHMARK_DRAW_LINE();
+BENCHMARK(reverse, iters) {
+  uint64_t b = 0;
+  for (unsigned long i = 0; i < iters; ++i) {
+    b = folly::bitReverse(i + b);
+    folly::doNotOptimizeAway(b);
+  }
+}
+
 int main(int argc, char** argv) {
   gflags::ParseCommandLineFlags(&argc, &argv, true);
   folly::runBenchmarks();
@@ -48,7 +57,13 @@ int main(int argc, char** argv) {
 Benchmarks run on dual Xeon X5650's @ 2.67GHz w/hyperthreading enabled
   (12 physical cores, 12 MB cache, 72 GB RAM)
 
-Benchmark                               Iters   Total t    t/iter iter/sec
-------------------------------------------------------------------------------
-*       nextPowTwoClz                 1000000  1.659 ms  1.659 ns  574.8 M
+============================================================================
+folly/test/BitsBenchmark.cpp                    relative  time/iter  iters/s
+============================================================================
+nextPowTwoClz                                                0.00fs  Infinity
+----------------------------------------------------------------------------
+isPowTwo                                                   731.61ps    1.37G
+----------------------------------------------------------------------------
+reverse                                                      4.84ns  206.58M
+============================================================================
 */