[libc-commits] [PATCH] D86162: [libc] Add two-way strstr algorithm.

Chris Gyurgyik via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Aug 19 10:55:10 PDT 2020

cgyurgyik added a comment.

QuickBenchmark <https://quick-bench.com/q/yx-NBWHjX4ntVKjeIhZylNWt1w8>

I've provided some quick benchmarks, which takes a string of length N and uses both the two-way algorithm and the brute force algorithm on a relatively short needle. This is run 4 times with the following placements:

1. Needle in the beginning.
2. Needle in the middle.
3. Needle in the end.
4. Needle not in the string.

What this does **NOT** account for: long needles, patterns that might make the brute force or two-way algorithm worse.
Without profiling, this obviously doesn't mean much, but gives us some idea of where the change-over may be. Given a longer needle, this will only favor the two-way algorithm.

F12696076: yx-NBWHjX4ntVKjeIhZylNWt1w8.png <https://reviews.llvm.org/F12696076>

  rG LLVM Github Monorepo



More information about the libc-commits mailing list