benchmarks/string.bench.cpp
static void BM_StringFindMatch2(benchmark::State &state) {
  std::string s1(MAX_STRING_LEN / 2, '*');
  s1 += std::string(state.range(0), '-');
  s1 += std::string(state.range(0), '*');
  std::string s2(state.range(0), '-');
  while (state.KeepRunning())
    benchmark::DoNotOptimize(s1.find(s2));
}
// Benchmark when the string matches somewhere from middle to the end.
Benchmark when the string matches somewhere from middle to the end.
Benchmark when the string matches somewhere from middle to the end .
static void BM_StringFindMatch2(benchmark::State &state) {
  std::string s1(MAX_STRING_LEN / 2, '*');
  s1 += std::string(state.range(0), '-');
  s1 += std::string(state.range(0), '*');
  std::string s2(state.range(0), '-');
  while (state.KeepRunning())
    benchmark::DoNotOptimize(s1.find(s2));
}
static void BM_StringFindMatch2 ( benchmark :: State & state ) { std :: string s1 ( MAX_STRING_LEN / 2 , ' ' ) ; s1 += std :: string ( state . range ( 0 ) , ' ' ) ; s1 += std :: string ( state . range ( 0 ) , ' ' ) ; std :: string s2 ( state . range ( 0 ) , ' ' ) ; while ( state . KeepRunning ( ) ) benchmark :: DoNotOptimize ( s1 . find ( s2 ) ) ; }
Benchmark when the string matches somewhere from middle to the end.
Benchmark when the string matches somewhere from middle to the end .