Search unpadded strings in Range benchmarks
authorYedidya Feldblum <yfeldblum@fb.com>
Wed, 23 Sep 2015 05:22:20 +0000 (22:22 -0700)
committerfacebook-github-bot-9 <folly-bot@fb.com>
Wed, 23 Sep 2015 06:20:16 +0000 (23:20 -0700)
Summary: [Folly] Search unpadded strings in `Range` benchmarks.

`vstr` has padding to adjust alignment. `vstrp` is a view into `vstr` that skips the padding, so that searches start out unaligned.

Before this diff, haystack is 8-byte aligned: `uintptr_t(haystack.begin()) % 8 == 0`. After this diff, it is not.

Reviewed By: @​@​nbronson

Differential Revision: D2468934

folly/test/RangeFindBenchmark.cpp

index 2c920b7246df5213444ecb19ca5e4c0f254a9db7..2194ebb45e9f83757f3dabf953df99124194f3cd 100644 (file)
@@ -167,7 +167,7 @@ void countHits(Func func, size_t n) {
 template <class Func>
 void findFirstOfRange(StringPiece needles, Func func, size_t n) {
   FOR_EACH_RANGE (i, 0, n) {
-    const StringPiece haystack = vstr[i % kVstrSize];
+    const StringPiece haystack = vstrp[i % kVstrSize];
     doNotOptimizeAway(func(haystack, needles));
     char x = haystack[0];
     doNotOptimizeAway(&x);