From ceddd293919a9580cef928fa56a35480de278682 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 9 Mar 2017 17:04:24 -0800 Subject: Address github comments --- test/cpp/microbenchmarks/bm_error.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/cpp/microbenchmarks/bm_error.cc') diff --git a/test/cpp/microbenchmarks/bm_error.cc b/test/cpp/microbenchmarks/bm_error.cc index 76f168b75b..c4f6aa19d5 100644 --- a/test/cpp/microbenchmarks/bm_error.cc +++ b/test/cpp/microbenchmarks/bm_error.cc @@ -83,6 +83,30 @@ static void BM_ErrorCreateAndSetIntAndStr(benchmark::State& state) { } BENCHMARK(BM_ErrorCreateAndSetIntAndStr); +static void BM_ErrorCreateAndSetIntLoop(benchmark::State& state) { + TrackCounters track_counters; + grpc_error* error = GRPC_ERROR_CREATE("Error"); + int n = 0; + while (state.KeepRunning()) { + error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS, n++); + } + GRPC_ERROR_UNREF(error); + track_counters.Finish(state); +} +BENCHMARK(BM_ErrorCreateAndSetIntLoop); + +static void BM_ErrorCreateAndSetStrLoop(benchmark::State& state) { + TrackCounters track_counters; + grpc_error* error = GRPC_ERROR_CREATE("Error"); + const char* str = "hello"; + while (state.KeepRunning()) { + error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, str); + } + GRPC_ERROR_UNREF(error); + track_counters.Finish(state); +} +BENCHMARK(BM_ErrorCreateAndSetStrLoop); + static void BM_ErrorRefUnref(benchmark::State& state) { TrackCounters track_counters; grpc_error* error = GRPC_ERROR_CREATE("Error"); -- cgit v1.2.3