Futex::futexWait returns FutexResult
[folly.git] / folly / test / FingerprintBenchmark.cpp
index 61709b676c86a2d4282f76fec83a9498aac2d480..012d3ddf124c99c239df757762cd72ad179f8df1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 
 #include <random>
+
 #include <folly/Benchmark.h>
+#include <folly/Fingerprint.h>
 #include <folly/Format.h>
 #include <folly/detail/SlowFingerprint.h>
-#include <folly/Fingerprint.h>
 
 using namespace std;
 using namespace folly;
@@ -43,7 +44,7 @@ void initialize() {
   // word length = uniformly distributed between 1 and 10
   // charset = 0x20 - 0x7f
   std::uniform_int_distribution<size_t> term_len(1, 10);
-  std::uniform_int_distribution<uint8_t> term_char(0x20, 0x7f);
+  std::uniform_int_distribution<uint16_t> term_char(0x20, 0x7f);
   for (int i = 0; i < kMaxTerms; i++) {
     std::string& term = terms[i];
     int len = term_len(rng);
@@ -116,33 +117,32 @@ void fastFingerprintTerms128(int num_iterations, int num_ids) {
   fingerprintTerms<Fingerprint<128> >(num_iterations, num_ids);
 }
 
-
-}  // namespace
+} // namespace
 
 // Only benchmark one size of slowFingerprint; it's significantly slower
 // than fastFingeprint (as you can see for 64 bits) and it just slows down
 // the benchmark without providing any useful data.
 
 int main(int argc, char** argv) {
-  initialize();
-    # define BM(name, min, max) \
-    for (size_t i = min; i <= max; i *= 2) { \
-      addBenchmark( \
-          __FILE__, \
-          sformat("{}_{}", #name, i).c_str(), \
-          [=](int iters) { name(iters, i); return iters; }); \
-    }
+  gflags::ParseCommandLineFlags(&argc, &argv, true);
+  # define BM(name, min, max) \
+  for (size_t i = min; i <= max; i *= 2) { \
+    addBenchmark( \
+        __FILE__, \
+        sformat("{}_{}", #name, i).c_str(), \
+        [=](int iters) { name(iters, i); return iters; }); \
+  }
+  BM(fastFingerprintIds64, 1, kMaxIds)
+  BM(slowFingerprintIds64, 1, kMaxIds)
+  BM(fastFingerprintIds96, 1, kMaxIds)
+  BM(fastFingerprintIds128, 1, kMaxIds)
+  BM(fastFingerprintTerms64, 1, kMaxTerms)
+  BM(slowFingerprintTerms64, 1, kMaxTerms)
+  BM(fastFingerprintTerms96, 1, kMaxTerms)
+  BM(fastFingerprintTerms128, 1, kMaxTerms)
+  # undef BM
 
-      BM(fastFingerprintIds64, 1, kMaxIds)
-      BM(slowFingerprintIds64, 1, kMaxIds)
-      BM(fastFingerprintIds96, 1, kMaxIds)
-      BM(fastFingerprintIds128, 1, kMaxIds)
-      BM(fastFingerprintTerms64, 1, kMaxTerms)
-      BM(slowFingerprintTerms64, 1, kMaxTerms)
-      BM(fastFingerprintTerms96, 1, kMaxTerms)
-      BM(fastFingerprintTerms128, 1, kMaxTerms)
-      # undef BM
-
-    runBenchmarks();
-    return 0;
+  initialize();
+  runBenchmarks();
+  return 0;
 }