aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2018-03-04 19:28:57 -0800
committerGravatar Vijay Pai <vpai@google.com>2018-03-05 16:43:32 -0800
commit2f4161c210ba637114be7e34713aede5bbb05365 (patch)
treef42b3c5b79bfb248e308aa5caae4be9b668d5fb8 /test/cpp/microbenchmarks/bm_chttp2_hpack.cc
parent673439d5bd2d1711c10e8c4d29ceee3e67d585fd (diff)
Use stack frame size limits for consistency with internal builds
Diffstat (limited to 'test/cpp/microbenchmarks/bm_chttp2_hpack.cc')
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_hpack.cc28
1 files changed, 16 insertions, 12 deletions
diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
index 07bb3c92ae..d0f3ec8e8b 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
@@ -18,9 +18,11 @@
/* Microbenchmarks around CHTTP2 HPACK operations */
+#include <benchmark/benchmark.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <string.h>
+#include <memory>
#include <sstream>
#include "src/core/ext/transport/chttp2/transport/hpack_encoder.h"
@@ -31,7 +33,6 @@
#include "src/core/lib/transport/timeout_encoding.h"
#include "test/cpp/microbenchmarks/helpers.h"
-#include "third_party/benchmark/include/benchmark/benchmark.h"
auto& force_library_initialization = Library::get();
@@ -51,10 +52,11 @@ static grpc_slice MakeSlice(std::vector<uint8_t> bytes) {
static void BM_HpackEncoderInitDestroy(benchmark::State& state) {
TrackCounters track_counters;
grpc_core::ExecCtx exec_ctx;
- grpc_chttp2_hpack_compressor c;
+ std::unique_ptr<grpc_chttp2_hpack_compressor> c(
+ new grpc_chttp2_hpack_compressor);
while (state.KeepRunning()) {
- grpc_chttp2_hpack_compressor_init(&c);
- grpc_chttp2_hpack_compressor_destroy(&c);
+ grpc_chttp2_hpack_compressor_init(c.get());
+ grpc_chttp2_hpack_compressor_destroy(c.get());
grpc_core::ExecCtx::Get()->Flush();
}
@@ -71,8 +73,9 @@ static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) {
grpc_metadata_batch_init(&b);
b.deadline = saved_now + 30 * 1000;
- grpc_chttp2_hpack_compressor c;
- grpc_chttp2_hpack_compressor_init(&c);
+ std::unique_ptr<grpc_chttp2_hpack_compressor> c(
+ new grpc_chttp2_hpack_compressor);
+ grpc_chttp2_hpack_compressor_init(c.get());
grpc_transport_one_way_stats stats;
memset(&stats, 0, sizeof(stats));
grpc_slice_buffer outbuf;
@@ -85,12 +88,12 @@ static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) {
static_cast<size_t>(1024),
&stats,
};
- grpc_chttp2_encode_header(&c, nullptr, 0, &b, &hopt, &outbuf);
+ grpc_chttp2_encode_header(c.get(), nullptr, 0, &b, &hopt, &outbuf);
grpc_slice_buffer_reset_and_unref_internal(&outbuf);
grpc_core::ExecCtx::Get()->Flush();
}
grpc_metadata_batch_destroy(&b);
- grpc_chttp2_hpack_compressor_destroy(&c);
+ grpc_chttp2_hpack_compressor_destroy(c.get());
grpc_slice_buffer_destroy_internal(&outbuf);
std::ostringstream label;
@@ -120,8 +123,9 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) {
"addmd", grpc_metadata_batch_add_tail(&b, &storage[i], elems[i])));
}
- grpc_chttp2_hpack_compressor c;
- grpc_chttp2_hpack_compressor_init(&c);
+ std::unique_ptr<grpc_chttp2_hpack_compressor> c(
+ new grpc_chttp2_hpack_compressor);
+ grpc_chttp2_hpack_compressor_init(c.get());
grpc_transport_one_way_stats stats;
memset(&stats, 0, sizeof(stats));
grpc_slice_buffer outbuf;
@@ -134,7 +138,7 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) {
static_cast<size_t>(state.range(1)),
&stats,
};
- grpc_chttp2_encode_header(&c, nullptr, 0, &b, &hopt, &outbuf);
+ grpc_chttp2_encode_header(c.get(), nullptr, 0, &b, &hopt, &outbuf);
if (!logged_representative_output && state.iterations() > 3) {
logged_representative_output = true;
for (size_t i = 0; i < outbuf.count; i++) {
@@ -147,7 +151,7 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) {
grpc_core::ExecCtx::Get()->Flush();
}
grpc_metadata_batch_destroy(&b);
- grpc_chttp2_hpack_compressor_destroy(&c);
+ grpc_chttp2_hpack_compressor_destroy(c.get());
grpc_slice_buffer_destroy_internal(&outbuf);
std::ostringstream label;