From be7be7e244159b84c0a28d8082ef06f81cac83bc Mon Sep 17 00:00:00 2001 From: Jeremy Lilley Date: Thu, 9 Aug 2012 09:57:22 -0700 Subject: [PATCH] Add "short append" benchmark to fbstring benchmark suite. Summary: Appending many small strings to fbstring appears much slower (~3x) vs. std::string. Adding benchmark case to illustrate. [If this isn't wanted, I can revert] Test Plan: This is a benchmark. Reviewed By: soren@fb.com FB internal diff: D544159 --- folly/test/FBStringTestBenchmarks.cpp.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/folly/test/FBStringTestBenchmarks.cpp.h b/folly/test/FBStringTestBenchmarks.cpp.h index 15ddc650..1e29ed29 100644 --- a/folly/test/FBStringTestBenchmarks.cpp.h +++ b/folly/test/FBStringTestBenchmarks.cpp.h @@ -222,3 +222,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); -- 2.34.1