aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/microbenchmarks
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2018-03-12 14:21:10 -0700
committerGravatar GitHub <noreply@github.com>2018-03-12 14:21:10 -0700
commit2c6aee9cf7bb88ec35695887fe2a88b168519840 (patch)
tree12828dfe38c0305009da81a395fdf90031900f46 /test/cpp/microbenchmarks
parent41c396ec8880e696b7709d1b636a48fbd882b581 (diff)
parent2f4161c210ba637114be7e34713aede5bbb05365 (diff)
Merge pull request #14591 from vjpai/framesize
Build with stack frame size limits
Diffstat (limited to 'test/cpp/microbenchmarks')
-rw-r--r--test/cpp/microbenchmarks/BUILD7
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_hpack.cc28
2 files changed, 23 insertions, 12 deletions
diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD
index 0b69e9ba9a..67f7e440b0 100644
--- a/test/cpp/microbenchmarks/BUILD
+++ b/test/cpp/microbenchmarks/BUILD
@@ -143,3 +143,10 @@ grpc_cc_binary(
srcs = ["bm_metadata.cc"],
deps = [":helpers"],
)
+
+grpc_cc_binary(
+ name = "bm_chttp2_hpack",
+ testonly = 1,
+ srcs = ["bm_chttp2_hpack.cc"],
+ deps = [":helpers"],
+)
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;