Copyright 2013 -> 2014
[folly.git] / folly / test / FBStringTestBenchmarks.cpp.h
index 15ddc6509449972b3e1a13eef1838e4cee1662d6..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 {
@@ -222,3 +239,14 @@ BENCHMARK_PARAM(BENCHFUN(push_back), 1);
 BENCHMARK_PARAM(BENCHFUN(push_back), 23);
 BENCHMARK_PARAM(BENCHFUN(push_back), 127);
 BENCHMARK_PARAM(BENCHFUN(push_back), 1024);
+
+void BENCHFUN(short_append)(int iters, int arg) {
+  FOR_EACH_RANGE (i, 0, iters) {
+    STRING s;
+    FOR_EACH_RANGE (j, 0, arg) {
+      s += "012";
+    }
+  }
+}
+BENCHMARK_PARAM(BENCHFUN(short_append), 23);
+BENCHMARK_PARAM(BENCHFUN(short_append), 1024);