proxygen
HTTPHeadersBenchmark.cpp File Reference
#include <algorithm>
#include <folly/Benchmark.h>
#include <proxygen/lib/http/HTTPCommonHeaders.h>

Go to the source code of this file.

Functions

void HTTPCommonHeadersHashBench (int iters)
 
void HTTPCommonHeadersGetHeaderCodeFromTableCommonHeaderNameBench (int iters)
 
 BENCHMARK (HTTPCommonHeadersHash, iters)
 
 BENCHMARK (HTTPCommonHeadersGetHeaderCodeFromTableCommonHeaderName, iters)
 
void memchrBench (int iters)
 
void stdFindBench (int iters)
 
 BENCHMARK (memchr, iters)
 
 BENCHMARK (stdFind, iters)
 
int main (int argc, char **argv)
 

Function Documentation

BENCHMARK ( HTTPCommonHeadersHash  ,
iters   
)

Definition at line 78 of file HTTPHeadersBenchmark.cpp.

References HTTPCommonHeadersHashBench().

78  {
80 }
void HTTPCommonHeadersHashBench(int iters)
BENCHMARK ( HTTPCommonHeadersGetHeaderCodeFromTableCommonHeaderName  ,
iters   
)

Definition at line 82 of file HTTPHeadersBenchmark.cpp.

References HTTPCommonHeadersGetHeaderCodeFromTableCommonHeaderNameBench().

82  {
84 }
void HTTPCommonHeadersGetHeaderCodeFromTableCommonHeaderNameBench(int iters)
BENCHMARK ( memchr  ,
iters   
)

Definition at line 112 of file HTTPHeadersBenchmark.cpp.

References memchrBench().

112  {
113  memchrBench(iters);
114 }
void memchrBench(int iters)
BENCHMARK ( stdFind  ,
iters   
)

Definition at line 116 of file HTTPHeadersBenchmark.cpp.

References stdFindBench().

116  {
117  stdFindBench(iters);
118 }
void stdFindBench(int iters)
void HTTPCommonHeadersGetHeaderCodeFromTableCommonHeaderNameBench ( int  iters)

Definition at line 68 of file HTTPHeadersBenchmark.cpp.

References proxygen::HTTPHeaderCodeCommonOffset, i, proxygen::TABLE_CAMELCASE, and uint64_t.

Referenced by BENCHMARK().

68  {
69  for (int i = 0; i < iters; ++i) {
71  j < HTTPCommonHeaders::num_header_codes; ++j) {
72  HTTPCommonHeaders::getHeaderCodeFromTableCommonHeaderName(
73  &testHeaderNames[j], TABLE_CAMELCASE);
74  }
75  }
76 }
const uint8_t HTTPHeaderCodeCommonOffset
void HTTPCommonHeadersHashBench ( int  iters)

Definition at line 60 of file HTTPHeadersBenchmark.cpp.

References i.

Referenced by BENCHMARK().

60  {
61  for (int i = 0; i < iters; ++i) {
62  for (auto const& testHeaderString: testHeaderStrings) {
63  HTTPCommonHeaders::hash(*testHeaderString);
64  }
65  }
66 }
int main ( int  argc,
char **  argv 
)

Definition at line 120 of file HTTPHeadersBenchmark.cpp.

References folly::runBenchmarks().

120  {
121  gflags::ParseCommandLineFlags(&argc, &argv, true);
123  return 0;
124 }
void runBenchmarks()
Definition: Benchmark.cpp:456
char ** argv
void memchrBench ( int  iters)

Definition at line 86 of file HTTPHeadersBenchmark.cpp.

References proxygen::HTTPHeaderCodeCommonOffset, i, and uint64_t.

Referenced by BENCHMARK().

86  {
87  for (int i = 0; i < iters; ++i) {
89  j < HTTPCommonHeaders::num_header_codes; ++j) {
90  CHECK(
91  memchr(
92  (void*)testHeaderCodes.data(), static_cast<HTTPHeaderCode>(j),
93  testHeaderCodes.size()) != nullptr);
94  }
95  }
96 }
const uint8_t HTTPHeaderCodeCommonOffset
void stdFindBench ( int  iters)

Definition at line 98 of file HTTPHeadersBenchmark.cpp.

References proxygen::HTTPHeaderCodeCommonOffset, i, and uint64_t.

Referenced by BENCHMARK().

98  {
99  for (int i = 0; i < iters; ++i) {
101  j < HTTPCommonHeaders::num_header_codes; ++j) {
102  auto address = HTTPCommonHeaders::getPointerToHeaderName(
103  static_cast<HTTPHeaderCode>(j));
104  CHECK(
105  std::find(
106  testHeaderStrings.begin(), testHeaderStrings.end(), address) !=
107  testHeaderStrings.end());
108  }
109  }
110 }
const uint8_t HTTPHeaderCodeCommonOffset