proxygen
AsciiCaseInsensitiveBenchmark.cpp File Reference
#include <folly/Benchmark.h>
#include <folly/Range.h>
#include <algorithm>

Go to the source code of this file.

Classes

struct  AsciiCaseInsensitiveLegacy
 

Functions

template<typename Cmp >
void test_operator_on_search (int iters)
 
 BENCHMARK (LegacyCaseInsensitiveCheck, iters)
 
 BENCHMARK (CurrentCaseInsensitiveCheck, iters)
 
int main (int argc, char **argv)
 

Variables

string lorem_ipsum
 
const string needle = "commodo"
 

Function Documentation

BENCHMARK ( LegacyCaseInsensitiveCheck  ,
iters   
)

Definition at line 108 of file AsciiCaseInsensitiveBenchmark.cpp.

108  {
109  test_operator_on_search<AsciiCaseInsensitiveLegacy>(iters);
110 }
BENCHMARK ( CurrentCaseInsensitiveCheck  ,
iters   
)

Definition at line 112 of file AsciiCaseInsensitiveBenchmark.cpp.

112  {
113  test_operator_on_search<AsciiCaseInsensitive>(iters);
114 }
int main ( int  argc,
char **  argv 
)

Definition at line 116 of file AsciiCaseInsensitiveBenchmark.cpp.

References folly::runBenchmarks().

116  {
117  gflags::ParseCommandLineFlags(&argc, &argv, true);
119  if (FLAGS_benchmark) {
121  }
122  return 0;
123 }
void runBenchmarks()
Definition: Benchmark.cpp:456
char ** argv
template<typename Cmp >
void test_operator_on_search ( int  iters)
inline

Definition at line 93 of file AsciiCaseInsensitiveBenchmark.cpp.

References folly::doNotOptimizeAway(), dummy(), i, lorem_ipsum, and needle.

93  {
94  Cmp cmp;
95  int dummy = 0;
96  for (int i = 0; i < iters; ++i) {
97  dummy += std::search(
98  lorem_ipsum.begin(),
99  lorem_ipsum.end(),
100  needle.begin(),
101  needle.end(),
102  cmp) -
103  lorem_ipsum.begin();
104  }
105  doNotOptimizeAway(dummy);
106 }
const string needle
void dummy()
auto doNotOptimizeAway(const T &datum) -> typename std::enable_if< !detail::DoNotOptimizeAwayNeedsIndirect< T >::value >::type
Definition: Benchmark.h:258

Variable Documentation

string lorem_ipsum

Definition at line 25 of file AsciiCaseInsensitiveBenchmark.cpp.

Referenced by test_operator_on_search().