diff options
Diffstat (limited to 'test/cpp/microbenchmarks/bm_error.cc')
-rw-r--r-- | test/cpp/microbenchmarks/bm_error.cc | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/test/cpp/microbenchmarks/bm_error.cc b/test/cpp/microbenchmarks/bm_error.cc index bd5f02e172..56b80dfcf6 100644 --- a/test/cpp/microbenchmarks/bm_error.cc +++ b/test/cpp/microbenchmarks/bm_error.cc @@ -159,39 +159,39 @@ BENCHMARK(BM_ErrorGetPresentInt); // Fixtures for tests: generate different kinds of errors class ErrorNone { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return GRPC_ERROR_NONE; } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; }; class ErrorCancelled { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return GRPC_ERROR_CANCELLED; } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; }; class SimpleError { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return error_.get(); } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; ErrorPtr error_{GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error")}; }; class ErrorWithGrpcStatus { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return error_.get(); } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; ErrorPtr error_{grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNIMPLEMENTED)}; @@ -199,11 +199,11 @@ class ErrorWithGrpcStatus { class ErrorWithHttpError { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return error_.get(); } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; ErrorPtr error_{grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_COMPRESSION_ERROR)}; @@ -211,11 +211,11 @@ class ErrorWithHttpError { class ErrorWithNestedGrpcStatus { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return error_.get(); } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; ErrorPtr nested_error_{grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNIMPLEMENTED)}; @@ -248,12 +248,14 @@ template <class Fixture> static void BM_ErrorGetStatus(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { grpc_status_code status; grpc_slice slice; - grpc_error_get_status(fixture.error(), fixture.deadline(), &status, &slice, - NULL); + grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(), + &status, &slice, NULL); } + grpc_exec_ctx_finish(&exec_ctx); track_counters.Finish(state); } @@ -261,11 +263,13 @@ template <class Fixture> static void BM_ErrorGetStatusCode(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { grpc_status_code status; - grpc_error_get_status(fixture.error(), fixture.deadline(), &status, NULL, - NULL); + grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(), + &status, NULL, NULL); } + grpc_exec_ctx_finish(&exec_ctx); track_counters.Finish(state); } @@ -273,11 +277,13 @@ template <class Fixture> static void BM_ErrorHttpError(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { grpc_http2_error_code error; - grpc_error_get_status(fixture.error(), fixture.deadline(), NULL, NULL, - &error); + grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(), NULL, + NULL, &error); } + grpc_exec_ctx_finish(&exec_ctx); track_counters.Finish(state); } |