diff options
author | Sree Kuchibhotla <sreek@google.com> | 2017-12-08 10:19:56 -0800 |
---|---|---|
committer | Sree Kuchibhotla <sreek@google.com> | 2017-12-08 10:19:56 -0800 |
commit | ca398ee74a7aed2a45ae58e3c5753c4c99e4d683 (patch) | |
tree | 0e49ba3759a117b66c598158d6ba745178a8ffce /test/cpp/microbenchmarks/bm_pollset.cc | |
parent | 54961bb9e16f84d193077277f7d2d8269f57a411 (diff) | |
parent | 94e676e10f8c739289924b8458a246699e3623ce (diff) |
Merge branch 'master' into cv-wait-monotonic
Diffstat (limited to 'test/cpp/microbenchmarks/bm_pollset.cc')
-rw-r--r-- | test/cpp/microbenchmarks/bm_pollset.cc | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc index 4da79693f1..d9d5164cce 100644 --- a/test/cpp/microbenchmarks/bm_pollset.cc +++ b/test/cpp/microbenchmarks/bm_pollset.cc @@ -41,8 +41,8 @@ auto& force_library_initialization = Library::get(); -static void shutdown_ps(grpc_exec_ctx* exec_ctx, void* ps, grpc_error* error) { - grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(ps)); +static void shutdown_ps(void* ps, grpc_error* error) { + grpc_pollset_destroy(static_cast<grpc_pollset*>(ps)); } static void BM_CreateDestroyPollset(benchmark::State& state) { @@ -50,7 +50,7 @@ static void BM_CreateDestroyPollset(benchmark::State& state) { size_t ps_sz = grpc_pollset_size(); grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_malloc(ps_sz)); gpr_mu* mu; - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_core::ExecCtx exec_ctx; grpc_closure shutdown_ps_closure; GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps, grpc_schedule_on_exec_ctx); @@ -58,11 +58,11 @@ static void BM_CreateDestroyPollset(benchmark::State& state) { memset(ps, 0, ps_sz); grpc_pollset_init(ps, &mu); gpr_mu_lock(mu); - grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure); + grpc_pollset_shutdown(ps, &shutdown_ps_closure); gpr_mu_unlock(mu); - grpc_exec_ctx_flush(&exec_ctx); + grpc_core::ExecCtx::Get()->Flush(); } - grpc_exec_ctx_finish(&exec_ctx); + grpc_core::ExecCtx::Get()->Flush(); gpr_free(ps); track_counters.Finish(state); } @@ -114,17 +114,17 @@ static void BM_PollEmptyPollset(benchmark::State& state) { grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_zalloc(ps_sz)); gpr_mu* mu; grpc_pollset_init(ps, &mu); - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_core::ExecCtx exec_ctx; gpr_mu_lock(mu); while (state.KeepRunning()) { - GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, nullptr, 0)); + GRPC_ERROR_UNREF(grpc_pollset_work(ps, nullptr, 0)); } grpc_closure shutdown_ps_closure; GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps, grpc_schedule_on_exec_ctx); - grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure); + grpc_pollset_shutdown(ps, &shutdown_ps_closure); gpr_mu_unlock(mu); - grpc_exec_ctx_finish(&exec_ctx); + grpc_core::ExecCtx::Get()->Flush(); gpr_free(ps); track_counters.Finish(state); } @@ -136,24 +136,23 @@ static void BM_PollAddFd(benchmark::State& state) { grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_zalloc(ps_sz)); gpr_mu* mu; grpc_pollset_init(ps, &mu); - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_core::ExecCtx exec_ctx; grpc_wakeup_fd wakeup_fd; GPR_ASSERT( GRPC_LOG_IF_ERROR("wakeup_fd_init", grpc_wakeup_fd_init(&wakeup_fd))); grpc_fd* fd = grpc_fd_create(wakeup_fd.read_fd, "xxx"); while (state.KeepRunning()) { - grpc_pollset_add_fd(&exec_ctx, ps, fd); - grpc_exec_ctx_flush(&exec_ctx); + grpc_pollset_add_fd(ps, fd); + grpc_core::ExecCtx::Get()->Flush(); } - grpc_fd_orphan(&exec_ctx, fd, nullptr, nullptr, false /* already_closed */, - "xxx"); + grpc_fd_orphan(fd, nullptr, nullptr, false /* already_closed */, "xxx"); grpc_closure shutdown_ps_closure; GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps, grpc_schedule_on_exec_ctx); gpr_mu_lock(mu); - grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure); + grpc_pollset_shutdown(ps, &shutdown_ps_closure); gpr_mu_unlock(mu); - grpc_exec_ctx_finish(&exec_ctx); + grpc_core::ExecCtx::Get()->Flush(); gpr_free(ps); track_counters.Finish(state); } @@ -170,7 +169,7 @@ Closure* MakeClosure(F f, grpc_closure_scheduler* scheduler) { C(F f, grpc_closure_scheduler* scheduler) : f_(f) { GRPC_CLOSURE_INIT(this, C::cbfn, this, scheduler); } - static void cbfn(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { + static void cbfn(void* arg, grpc_error* error) { C* p = static_cast<C*>(arg); p->f_(); } @@ -219,11 +218,11 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) { grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_zalloc(ps_sz)); gpr_mu* mu; grpc_pollset_init(ps, &mu); - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_core::ExecCtx exec_ctx; grpc_wakeup_fd wakeup_fd; GRPC_ERROR_UNREF(grpc_wakeup_fd_init(&wakeup_fd)); grpc_fd* wakeup = grpc_fd_create(wakeup_fd.read_fd, "wakeup_read"); - grpc_pollset_add_fd(&exec_ctx, ps, wakeup); + grpc_pollset_add_fd(ps, wakeup); bool done = false; Closure* continue_closure = MakeClosure( [&]() { @@ -233,25 +232,23 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) { return; } GRPC_ERROR_UNREF(grpc_wakeup_fd_wakeup(&wakeup_fd)); - grpc_fd_notify_on_read(&exec_ctx, wakeup, continue_closure); + grpc_fd_notify_on_read(wakeup, continue_closure); }, grpc_schedule_on_exec_ctx); GRPC_ERROR_UNREF(grpc_wakeup_fd_wakeup(&wakeup_fd)); - grpc_fd_notify_on_read(&exec_ctx, wakeup, continue_closure); + grpc_fd_notify_on_read(wakeup, continue_closure); gpr_mu_lock(mu); while (!done) { - GRPC_ERROR_UNREF( - grpc_pollset_work(&exec_ctx, ps, nullptr, GRPC_MILLIS_INF_FUTURE)); + GRPC_ERROR_UNREF(grpc_pollset_work(ps, nullptr, GRPC_MILLIS_INF_FUTURE)); } - grpc_fd_orphan(&exec_ctx, wakeup, nullptr, nullptr, - false /* already_closed */, "done"); + grpc_fd_orphan(wakeup, nullptr, nullptr, false /* already_closed */, "done"); wakeup_fd.read_fd = 0; grpc_closure shutdown_ps_closure; GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps, grpc_schedule_on_exec_ctx); - grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure); + grpc_pollset_shutdown(ps, &shutdown_ps_closure); gpr_mu_unlock(mu); - grpc_exec_ctx_finish(&exec_ctx); + grpc_core::ExecCtx::Get()->Flush(); grpc_wakeup_fd_destroy(&wakeup_fd); gpr_free(ps); track_counters.Finish(state); |