folly copyright 2015 -> copyright 2016
[folly.git] / folly / test / FormatBenchmark.cpp
index 6d4b76a4b021b5cd83b9fcfcf8ea51c0c754213b..dda8980238f2e639189f7bb14e7e3729cdff4715 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2012 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * limitations under the License.
  */
 
-#include "folly/Format.h"
+#include <folly/Format.h>
 
 #include <glog/logging.h>
 
-#include "folly/FBVector.h"
-#include "folly/Benchmark.h"
-#include "folly/dynamic.h"
-#include "folly/json.h"
+#include <folly/FBVector.h>
+#include <folly/Benchmark.h>
+#include <folly/dynamic.h>
+#include <folly/json.h>
 
 using namespace folly;
 
@@ -123,6 +123,44 @@ BENCHMARK_RELATIVE(bigFormat_format, iters) {
   }
 }
 
+BENCHMARK_DRAW_LINE()
+
+BENCHMARK(format_nested_strings, iters) {
+  while (iters--) {
+    fbstring out;
+    for (int i = 0; i < 1000; ++i) {
+      out.clear();
+      format(&out, "{} {}",
+             format("{} {}", i, i + 1).str(),
+             format("{} {}", -i, -i - 1).str());
+    }
+  }
+}
+
+BENCHMARK_RELATIVE(format_nested_fbstrings, iters) {
+  while (iters--) {
+    fbstring out;
+    for (int i = 0; i < 1000; ++i) {
+      out.clear();
+      format(&out, "{} {}",
+             format("{} {}", i, i + 1).fbstr(),
+             format("{} {}", -i, -i - 1).fbstr());
+    }
+  }
+}
+
+BENCHMARK_RELATIVE(format_nested_direct, iters) {
+  while (iters--) {
+    fbstring out;
+    for (int i = 0; i < 1000; ++i) {
+      out.clear();
+      format(&out, "{} {}",
+             format("{} {}", i, i + 1),
+             format("{} {}", -i, -i - 1));
+    }
+  }
+}
+
 // Benchmark results on my dev server (dual-CPU Xeon L5520 @ 2.7GHz)
 //
 // ============================================================================
@@ -143,7 +181,7 @@ BENCHMARK_RELATIVE(bigFormat_format, iters) {
 // ============================================================================
 
 int main(int argc, char *argv[]) {
-  google::ParseCommandLineFlags(&argc, &argv, true);
+  gflags::ParseCommandLineFlags(&argc, &argv, true);
   runBenchmarks();
   return 0;
 }