From: Jeremy Lilley Date: Thu, 9 Aug 2012 16:57:22 +0000 (-0700) Subject: Add "short append" benchmark to fbstring benchmark suite. X-Git-Tag: v0.22.0~1218 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=be7be7e244159b84c0a28d8082ef06f81cac83bc;p=folly.git 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 --- 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);