Short-circuit operator== based on size()
[folly.git] / folly / test / FBStringBenchmark.cpp
index 65fb652505b1fd9f0b1926a49ac5a285e44e5487..e9cd297b6a074ac02b1d45c8004ad12cf4fe8328 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2012 Facebook, Inc.
+ * Copyright 2013 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -56,6 +56,15 @@ void randomString(String* toFill, unsigned int maxSize = 1000) {
   }
 }
 
+template <class String>
+void randomBinaryString(String* toFill, unsigned int maxSize = 1000) {
+  assert(toFill);
+  toFill->resize(random(0, maxSize));
+  FOR_EACH (i, *toFill) {
+    *i = random('0', '1');
+  }
+}
+
 template <class String, class Integral>
 void Num2String(String& str, Integral n) {
   str.resize(30, '\0');