Add benchmarks similar to `stringPrintf` for `folly::Format` and `fmt`
Summary: Basic benchmarks to validate performance of similar string formatting functions. Notably, `stringPrintf` is always inferior to either format-based alternative. ``` ============================================================================ folly/test/StringBenchmark.cpp relative time/iter iters/s ============================================================================ libc_tolower 714.38ns 1.40M folly_toLowerAscii 66.03ns 15.14M stringPrintfOutputSize(1) 170.06ns 5.88M stringPrintfOutputSize(4) 198.54ns 5.04M stringPrintfOutputSize(16) 202.94ns 4.93M stringPrintfOutputSize(64) 204.82ns 4.88M stringPrintfOutputSize(256) 1.32us 759.95K stringPrintfOutputSize(1024) 4.47us 223.70K stringPrintfAppendfBenchmark 25.38ms 39.40 fmtOutputSize(1) 104.62ns 9.56M fmtOutputSize(4) 121.50ns 8.23M fmtOutputSize(16) 125.27ns 7.98M fmtOutputSize(64) 125.59ns 7.96M fmtOutputSize(256) 633.15ns 1.58M fmtOutputSize(1024) 1.06us 939.38K fmtAppendfBenchmark 8.22ms 121.71 follyFmtOutputSize(1) 122.76ns 8.15M follyFmtOutputSize(4) 149.51ns 6.69M follyFmtOutputSize(16) 148.90ns 6.72M follyFmtOutputSize(64) 147.45ns 6.78M follyFmtOutputSize(256) 150.71ns 6.64M follyFmtOutputSize(1024) 584.94ns 1.71M follyFmtAppendfBenchmark 11.39ms 87.79 BM_cEscape 321.10us 3.11K BM_cUnescape 290.97us 3.44K BM_uriEscape 2.99us 333.92K BM_uriUnescape 1.56us 639.36K BM_unhexlify 525.33ps 1.90G splitOnSingleChar 1.21us 823.13K splitOnSingleCharFixed 466.79ns 2.14M splitOnSingleCharFixedAllowExtra 0.00fs Infinity splitStr 1.86us 536.53K splitStrFixed 620.41ns 1.61M boost_splitOnSingleChar 2.34us 427.23K joinCharStr 947.58ns 1.06M joinStrStr 956.37ns 1.05M joinInt 2.24us 447.21K ============================================================================ ``` Reviewed By: vitaut Differential Revision: D13940303 fbshipit-source-id: a26d984cde26b1a5eb3eba1935722cdcd221fe44
Showing
Please register or sign in to comment