diff options
-rw-r--r-- | test/cpp/microbenchmarks/bm_fullstack.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/test/cpp/microbenchmarks/bm_fullstack.cc b/test/cpp/microbenchmarks/bm_fullstack.cc index c5ace53ff9..32fd535165 100644 --- a/test/cpp/microbenchmarks/bm_fullstack.cc +++ b/test/cpp/microbenchmarks/bm_fullstack.cc @@ -54,6 +54,7 @@ extern "C" { #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/completion_queue.h" #include "src/core/lib/surface/server.h" +#include "test/core/util/memory_counters.h" #include "test/core/util/passthru_endpoint.h" #include "test/core/util/port.h" } @@ -67,6 +68,7 @@ namespace testing { static class InitializeStuff { public: InitializeStuff() { + grpc_memory_counters_init(); init_lib_.init(); rq_ = grpc_resource_quota_create("bm"); } @@ -104,11 +106,15 @@ class BaseFixture { std::ostringstream out; this->AddToLabel(out, s); #ifdef GPR_MU_COUNTERS - out << " locks/iteration:" - << ((double)(gpr_atm_no_barrier_load(&grpc_mu_locks) - - mu_locks_at_start_) / - (double)s.iterations()); + out << " locks/iter:" << ((double)(gpr_atm_no_barrier_load(&grpc_mu_locks) - + mu_locks_at_start_) / + (double)s.iterations()); #endif + grpc_memory_counters counters_at_end = grpc_memory_counters_snapshot(); + out << " allocs/iter:" + << ((double)(counters_at_end.total_allocs_absolute - + counters_at_start_.total_allocs_absolute) / + (double)s.iterations()); auto label = out.str(); if (label.length() && label[0] == ' ') { label = label.substr(1); @@ -122,6 +128,7 @@ class BaseFixture { #ifdef GPR_MU_COUNTERS const size_t mu_locks_at_start_ = gpr_atm_no_barrier_load(&grpc_mu_locks); #endif + grpc_memory_counters counters_at_start_ = grpc_memory_counters_snapshot(); }; class FullstackFixture : public BaseFixture { @@ -272,7 +279,7 @@ class InProcessCHTTP2 : public EndpointPairFixture { : EndpointPairFixture(service, MakeEndpoints()) {} void AddToLabel(std::ostream& out, benchmark::State& state) { - out << " writes/iteration:" + out << " writes/iter:" << ((double)stats_.num_writes / (double)state.iterations()); } |