Copyright 2013 -> 2014
[folly.git] / folly / test / FBStringTestBenchmarks.cpp.h
index 1e29ed29e60bf93ae1bc6c9cb9b4b19085e507df..aba36e1447282ad04176813b15a9b8b8b68b223a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2012 Facebook, Inc.
+ * Copyright 2014 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -190,6 +190,23 @@ expect to get a call for an interview.";
 }
 BENCHMARK_PARAM(BENCHFUN(findUnsuccessful), 524288);
 
+void BENCHFUN(equality)(int iters, int arg) {
+  std::vector<STRING> haystack(arg);
+
+  BENCHMARK_SUSPEND {
+    for (auto& hay : haystack) {
+      randomBinaryString(&hay, 1024);
+    }
+  }
+
+  FOR_EACH_RANGE (i, 0, iters) {
+    STRING needle;
+    randomBinaryString(&needle, 1024);
+    doNotOptimizeAway(std::find(haystack.begin(), haystack.end(), needle));
+  }
+}
+BENCHMARK_PARAM(BENCHFUN(equality), 65536);
+
 void BENCHFUN(replace)(int iters, int arg) {
   STRING s;
   BENCHMARK_SUSPEND {