proxygen
HPACKBenchmark.cpp File Reference

Go to the source code of this file.

Functions

unique_ptr< IOBufencode (vector< HPACKHeader > &headers, HPACKEncoder &encoder)
 
void encodeDecode (vector< HPACKHeader > &headers, HPACKEncoder &encoder, HPACKDecoder &decoder)
 
vector< HPACKHeadergetHeaders ()
 
void encodeBench (int reencodes, int iters)
 
void encodeDecodeBench (int reencodes, int iters)
 
 BENCHMARK (Encode, iters)
 
 BENCHMARK (Encode1, iters)
 
 BENCHMARK (Encode2, iters)
 
 BENCHMARK (EncodeDecode, iters)
 
 BENCHMARK (EncodeDecode1, iters)
 
 BENCHMARK (EncodeDecode2, iters)
 
int main (int argc, char **argv)
 

Function Documentation

BENCHMARK ( Encode  ,
iters   
)

Definition at line 81 of file HPACKBenchmark.cpp.

References encodeBench().

81  {
82  encodeBench(0, iters);
83 }
void encodeBench(int reencodes, int iters)
BENCHMARK ( Encode1  ,
iters   
)

Definition at line 85 of file HPACKBenchmark.cpp.

References encodeBench().

85  {
86  encodeBench(1, iters);
87 }
void encodeBench(int reencodes, int iters)
BENCHMARK ( Encode2  ,
iters   
)

Definition at line 89 of file HPACKBenchmark.cpp.

References encodeBench().

89  {
90  encodeBench(2, iters);
91 }
void encodeBench(int reencodes, int iters)
BENCHMARK ( EncodeDecode  ,
iters   
)

Definition at line 93 of file HPACKBenchmark.cpp.

References encodeDecodeBench().

93  {
94  encodeDecodeBench(0, iters);
95 }
void encodeDecodeBench(int reencodes, int iters)
BENCHMARK ( EncodeDecode1  ,
iters   
)

Definition at line 97 of file HPACKBenchmark.cpp.

References encodeDecodeBench().

97  {
98  encodeDecodeBench(1, iters);
99 }
void encodeDecodeBench(int reencodes, int iters)
BENCHMARK ( EncodeDecode2  ,
iters   
)

Definition at line 101 of file HPACKBenchmark.cpp.

References encodeDecodeBench().

101  {
102  encodeDecodeBench(2, iters);
103 }
void encodeDecodeBench(int reencodes, int iters)
void encodeBench ( int  reencodes,
int  iters 
)

Definition at line 60 of file HPACKBenchmark.cpp.

References encode(), and i.

Referenced by BENCHMARK().

60  {
61  for (int i = 0; i < iters; i++) {
62  HPACKEncoder encoder(true);
63  encode(headers, encoder);
64  for (int j = 0; j < reencodes; j++) {
65  encode(headers, encoder);
66  }
67  }
68 }
unique_ptr< IOBuf > encode(vector< HPACKHeader > &headers, HPACKEncoder &encoder)
void encodeDecode ( vector< HPACKHeader > &  headers,
HPACKEncoder encoder,
HPACKDecoder decoder 
)

Definition at line 26 of file HPACKBenchmark.cpp.

References c, proxygen::HPACKDecoder::decodeStreaming(), encode(), and proxygen::TestStreamingCallback::hasError().

Referenced by encodeDecodeBench(), isLowercase(), TEST_F(), and TEST_P().

27  {
28  unique_ptr<IOBuf> encoded = encode(headers, encoder);
29  CHECK(encoded);
31  folly::io::Cursor c(encoded.get());
32  decoder.decodeStreaming(c, c.totalLength(), &cb);
33  CHECK(!cb.hasError());
34 }
unique_ptr< IOBuf > encode(vector< HPACKHeader > &headers, HPACKEncoder &encoder)
void decodeStreaming(folly::io::Cursor &cursor, uint32_t totalBytes, HPACK::StreamingCallback *streamingCb)
char c
void encodeDecodeBench ( int  reencodes,
int  iters 
)

Definition at line 70 of file HPACKBenchmark.cpp.

References encodeDecode(), and i.

Referenced by BENCHMARK().

70  {
71  for (int i = 0; i < iters; i++) {
72  HPACKEncoder encoder(true);
73  HPACKDecoder decoder;
74  encodeDecode(headers, encoder, decoder);
75  for (int j = 0; j < reencodes; j++) {
76  encodeDecode(headers, encoder, decoder);
77  }
78  }
79 }
void encodeDecode(vector< HPACKHeader > &headers, HPACKEncoder &encoder, HPACKDecoder &decoder)
vector<HPACKHeader> getHeaders ( )

Definition at line 37 of file HPACKBenchmark.cpp.

37  {
38  vector<HPACKHeader> headers;
39  headers.emplace_back(":authority", "www.facebook.com");
40  headers.emplace_back(":method", "GET");
41  headers.emplace_back(":path", "/graphql");
42  headers.emplace_back(":scheme", "https");
43  headers.emplace_back(
44  "user-agent",
45  "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 "
46  "(KHTML, like Gecko) Chrome/60.0.3100.0 Safari/537.36");
47  headers.emplace_back("accept-encoding", "gzip, deflate, br");
48  headers.emplace_back("accept-language", "en-US,en;q=0.8");
49  headers.emplace_back(
50  "accept",
51  "text/html,application/xhtml+xml,application/xml;q=0.9,image/"
52  "webp,image/apng,*/*;q=0.8");
53  return headers;
54 }
int main ( int  argc,
char **  argv 
)

Definition at line 105 of file HPACKBenchmark.cpp.

References folly::runBenchmarks().

105  {
106  gflags::ParseCommandLineFlags(&argc, &argv, true);
108  return 0;
109 }
void runBenchmarks()
Definition: Benchmark.cpp:456
char ** argv