aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/cpp/microbenchmarks/bm_chttp2_hpack.cc')
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_hpack.cc80
1 files changed, 43 insertions, 37 deletions
diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
index bc2157b9f1..f8c31910fe 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
@@ -33,11 +33,11 @@ extern "C" {
#include "test/cpp/microbenchmarks/helpers.h"
#include "third_party/benchmark/include/benchmark/benchmark.h"
-auto &force_library_initialization = Library::get();
+auto& force_library_initialization = Library::get();
static grpc_slice MakeSlice(std::vector<uint8_t> bytes) {
grpc_slice s = grpc_slice_malloc(bytes.size());
- uint8_t *p = GRPC_SLICE_START_PTR(s);
+ uint8_t* p = GRPC_SLICE_START_PTR(s);
for (auto b : bytes) {
*p++ = b;
}
@@ -48,7 +48,7 @@ static grpc_slice MakeSlice(std::vector<uint8_t> bytes) {
// HPACK encoder
//
-static void BM_HpackEncoderInitDestroy(benchmark::State &state) {
+static void BM_HpackEncoderInitDestroy(benchmark::State& state) {
TrackCounters track_counters;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_chttp2_hpack_compressor c;
@@ -62,7 +62,7 @@ static void BM_HpackEncoderInitDestroy(benchmark::State &state) {
}
BENCHMARK(BM_HpackEncoderInitDestroy);
-static void BM_HpackEncoderEncodeDeadline(benchmark::State &state) {
+static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) {
TrackCounters track_counters;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_millis saved_now = grpc_exec_ctx_now(&exec_ctx);
@@ -95,17 +95,19 @@ static void BM_HpackEncoderEncodeDeadline(benchmark::State &state) {
grpc_exec_ctx_finish(&exec_ctx);
std::ostringstream label;
- label << "framing_bytes/iter:" << (static_cast<double>(stats.framing_bytes) /
- static_cast<double>(state.iterations()))
- << " header_bytes/iter:" << (static_cast<double>(stats.header_bytes) /
- static_cast<double>(state.iterations()));
+ label << "framing_bytes/iter:"
+ << (static_cast<double>(stats.framing_bytes) /
+ static_cast<double>(state.iterations()))
+ << " header_bytes/iter:"
+ << (static_cast<double>(stats.header_bytes) /
+ static_cast<double>(state.iterations()));
track_counters.AddLabel(label.str());
track_counters.Finish(state);
}
BENCHMARK(BM_HpackEncoderEncodeDeadline);
template <class Fixture>
-static void BM_HpackEncoderEncodeHeader(benchmark::State &state) {
+static void BM_HpackEncoderEncodeHeader(benchmark::State& state) {
TrackCounters track_counters;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
static bool logged_representative_output = false;
@@ -138,7 +140,7 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State &state) {
if (!logged_representative_output && state.iterations() > 3) {
logged_representative_output = true;
for (size_t i = 0; i < outbuf.count; i++) {
- char *s = grpc_dump_slice(outbuf.slices[i], GPR_DUMP_HEX);
+ char* s = grpc_dump_slice(outbuf.slices[i], GPR_DUMP_HEX);
gpr_log(GPR_DEBUG, "%" PRIdPTR ": %s", i, s);
gpr_free(s);
}
@@ -152,10 +154,12 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State &state) {
grpc_exec_ctx_finish(&exec_ctx);
std::ostringstream label;
- label << "framing_bytes/iter:" << (static_cast<double>(stats.framing_bytes) /
- static_cast<double>(state.iterations()))
- << " header_bytes/iter:" << (static_cast<double>(stats.header_bytes) /
- static_cast<double>(state.iterations()));
+ label << "framing_bytes/iter:"
+ << (static_cast<double>(stats.framing_bytes) /
+ static_cast<double>(state.iterations()))
+ << " header_bytes/iter:"
+ << (static_cast<double>(stats.header_bytes) /
+ static_cast<double>(state.iterations()));
track_counters.AddLabel(label.str());
track_counters.Finish(state);
}
@@ -165,7 +169,7 @@ namespace hpack_encoder_fixtures {
class EmptyBatch {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
return {};
}
};
@@ -173,7 +177,7 @@ class EmptyBatch {
class SingleStaticElem {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
return {GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE};
}
};
@@ -181,7 +185,7 @@ class SingleStaticElem {
class SingleInternedElem {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
return {grpc_mdelem_from_slices(
exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")),
grpc_slice_intern(grpc_slice_from_static_string("def")))};
@@ -192,7 +196,7 @@ template <int kLength, bool kTrueBinary>
class SingleInternedBinaryElem {
public:
static constexpr bool kEnableTrueBinary = kTrueBinary;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
grpc_slice bytes = MakeBytes();
std::vector<grpc_mdelem> out = {grpc_mdelem_from_slices(
exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc-bin")),
@@ -214,7 +218,7 @@ class SingleInternedBinaryElem {
class SingleInternedKeyElem {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
return {grpc_mdelem_from_slices(
exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")),
grpc_slice_from_static_string("def"))};
@@ -224,7 +228,7 @@ class SingleInternedKeyElem {
class SingleNonInternedElem {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
return {grpc_mdelem_from_slices(exec_ctx,
grpc_slice_from_static_string("abc"),
grpc_slice_from_static_string("def"))};
@@ -235,7 +239,7 @@ template <int kLength, bool kTrueBinary>
class SingleNonInternedBinaryElem {
public:
static constexpr bool kEnableTrueBinary = kTrueBinary;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
return {grpc_mdelem_from_slices(
exec_ctx, grpc_slice_from_static_string("abc-bin"), MakeBytes())};
}
@@ -253,9 +257,10 @@ class SingleNonInternedBinaryElem {
class RepresentativeClientInitialMetadata {
public:
static constexpr bool kEnableTrueBinary = true;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
return {
- GRPC_MDELEM_SCHEME_HTTP, GRPC_MDELEM_METHOD_POST,
+ GRPC_MDELEM_SCHEME_HTTP,
+ GRPC_MDELEM_METHOD_POST,
grpc_mdelem_from_slices(
exec_ctx, GRPC_MDSTR_PATH,
grpc_slice_intern(grpc_slice_from_static_string("/foo/bar"))),
@@ -278,9 +283,10 @@ class RepresentativeClientInitialMetadata {
class MoreRepresentativeClientInitialMetadata {
public:
static constexpr bool kEnableTrueBinary = true;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
return {
- GRPC_MDELEM_SCHEME_HTTP, GRPC_MDELEM_METHOD_POST,
+ GRPC_MDELEM_SCHEME_HTTP,
+ GRPC_MDELEM_METHOD_POST,
grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_PATH,
grpc_slice_intern(grpc_slice_from_static_string(
"/grpc.test.FooService/BarMethod"))),
@@ -314,7 +320,7 @@ class MoreRepresentativeClientInitialMetadata {
class RepresentativeServerInitialMetadata {
public:
static constexpr bool kEnableTrueBinary = true;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
return {GRPC_MDELEM_STATUS_200,
GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP};
@@ -324,7 +330,7 @@ class RepresentativeServerInitialMetadata {
class RepresentativeServerTrailingMetadata {
public:
static constexpr bool kEnableTrueBinary = true;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
return {GRPC_MDELEM_GRPC_STATUS_0};
}
};
@@ -423,7 +429,7 @@ BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
// HPACK parser
//
-static void BM_HpackParserInitDestroy(benchmark::State &state) {
+static void BM_HpackParserInitDestroy(benchmark::State& state) {
TrackCounters track_counters;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_chttp2_hpack_parser p;
@@ -437,13 +443,13 @@ static void BM_HpackParserInitDestroy(benchmark::State &state) {
}
BENCHMARK(BM_HpackParserInitDestroy);
-static void UnrefHeader(grpc_exec_ctx *exec_ctx, void *user_data,
+static void UnrefHeader(grpc_exec_ctx* exec_ctx, void* user_data,
grpc_mdelem md) {
GRPC_MDELEM_UNREF(exec_ctx, md);
}
-template <class Fixture, void (*OnHeader)(grpc_exec_ctx *, void *, grpc_mdelem)>
-static void BM_HpackParserParseHeader(benchmark::State &state) {
+template <class Fixture, void (*OnHeader)(grpc_exec_ctx*, void*, grpc_mdelem)>
+static void BM_HpackParserParseHeader(benchmark::State& state) {
TrackCounters track_counters;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
std::vector<grpc_slice> init_slices = Fixture::GetInitSlices();
@@ -760,20 +766,20 @@ class RepresentativeServerTrailingMetadata {
}
};
-static void free_timeout(void *p) { gpr_free(p); }
+static void free_timeout(void* p) { gpr_free(p); }
// New implementation.
-static void OnHeaderNew(grpc_exec_ctx *exec_ctx, void *user_data,
+static void OnHeaderNew(grpc_exec_ctx* exec_ctx, void* user_data,
grpc_mdelem md) {
if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_TIMEOUT)) {
- grpc_millis *cached_timeout =
- static_cast<grpc_millis *>(grpc_mdelem_get_user_data(md, free_timeout));
+ grpc_millis* cached_timeout =
+ static_cast<grpc_millis*>(grpc_mdelem_get_user_data(md, free_timeout));
grpc_millis timeout;
if (cached_timeout != NULL) {
timeout = *cached_timeout;
} else {
if (!grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout)) {
- char *val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
+ char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'", val);
gpr_free(val);
timeout = GRPC_MILLIS_INF_FUTURE;
@@ -781,7 +787,7 @@ static void OnHeaderNew(grpc_exec_ctx *exec_ctx, void *user_data,
if (GRPC_MDELEM_IS_INTERNED(md)) {
/* not already parsed: parse it now, and store the
* result away */
- cached_timeout = (grpc_millis *)gpr_malloc(sizeof(grpc_millis));
+ cached_timeout = (grpc_millis*)gpr_malloc(sizeof(grpc_millis));
*cached_timeout = timeout;
grpc_mdelem_set_user_data(md, free_timeout, cached_timeout);
}