diff options
author | Craig Tiller <ctiller@google.com> | 2017-03-01 11:28:24 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-03-01 11:28:24 -0800 |
commit | 295df6da9aa8f6a51cd050ddf92f047d9179d9f2 (patch) | |
tree | 00e458067b742aeabd880906c2517b725f5abd9a /test/cpp | |
parent | 6517333d17e9c16e9f637320dc938b84dd248cc8 (diff) |
Add a slice type that shares a refcount with a transport stream
Diffstat (limited to 'test/cpp')
-rw-r--r-- | test/cpp/microbenchmarks/bm_metadata.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/cpp/microbenchmarks/bm_metadata.cc b/test/cpp/microbenchmarks/bm_metadata.cc index 7f81fbabcc..f468690834 100644 --- a/test/cpp/microbenchmarks/bm_metadata.cc +++ b/test/cpp/microbenchmarks/bm_metadata.cc @@ -36,8 +36,10 @@ #include <grpc/grpc.h> extern "C" { +#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/static_metadata.h" +#include "src/core/lib/transport/transport.h" } #include "third_party/benchmark/include/benchmark/benchmark.h" @@ -62,6 +64,19 @@ static void BM_SliceFromCopied(benchmark::State& state) { } BENCHMARK(BM_SliceFromCopied); +static void BM_SliceFromStreamOwnedBuffer(benchmark::State& state) { + grpc_stream_refcount r; + GRPC_STREAM_REF_INIT(&r, 1, NULL, NULL, "test"); + char buffer[64]; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + while (state.KeepRunning()) { + grpc_slice_unref_internal(&exec_ctx, grpc_slice_from_stream_owned_buffer( + &r, buffer, sizeof(buffer))); + } + grpc_exec_ctx_finish(&exec_ctx); +} +BENCHMARK(BM_SliceFromStreamOwnedBuffer); + static void BM_SliceIntern(benchmark::State& state) { gpr_slice slice = grpc_slice_from_static_string("abc"); while (state.KeepRunning()) { |