Add allocations/iteration counters to bm_fullstack

pull/9619/head
Craig Tiller 8 years ago
parent b038beb724
commit 01d7d9b2e5
  1. 13
      test/cpp/microbenchmarks/bm_fullstack.cc

@ -54,6 +54,7 @@ extern "C" {
#include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/completion_queue.h" #include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/server.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/passthru_endpoint.h"
#include "test/core/util/port.h" #include "test/core/util/port.h"
} }
@ -67,6 +68,7 @@ namespace testing {
static class InitializeStuff { static class InitializeStuff {
public: public:
InitializeStuff() { InitializeStuff() {
grpc_memory_counters_init();
init_lib_.init(); init_lib_.init();
rq_ = grpc_resource_quota_create("bm"); rq_ = grpc_resource_quota_create("bm");
} }
@ -104,11 +106,15 @@ class BaseFixture {
std::ostringstream out; std::ostringstream out;
this->AddToLabel(out, s); this->AddToLabel(out, s);
#ifdef GPR_MU_COUNTERS #ifdef GPR_MU_COUNTERS
out << " locks/iteration:" out << " locks/iter:" << ((double)(gpr_atm_no_barrier_load(&grpc_mu_locks) -
<< ((double)(gpr_atm_no_barrier_load(&grpc_mu_locks) -
mu_locks_at_start_) / mu_locks_at_start_) /
(double)s.iterations()); (double)s.iterations());
#endif #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(); auto label = out.str();
if (label.length() && label[0] == ' ') { if (label.length() && label[0] == ' ') {
label = label.substr(1); label = label.substr(1);
@ -122,6 +128,7 @@ class BaseFixture {
#ifdef GPR_MU_COUNTERS #ifdef GPR_MU_COUNTERS
const size_t mu_locks_at_start_ = gpr_atm_no_barrier_load(&grpc_mu_locks); const size_t mu_locks_at_start_ = gpr_atm_no_barrier_load(&grpc_mu_locks);
#endif #endif
grpc_memory_counters counters_at_start_ = grpc_memory_counters_snapshot();
}; };
class FullstackFixture : public BaseFixture { class FullstackFixture : public BaseFixture {
@ -272,7 +279,7 @@ class InProcessCHTTP2 : public EndpointPairFixture {
: EndpointPairFixture(service, MakeEndpoints()) {} : EndpointPairFixture(service, MakeEndpoints()) {}
void AddToLabel(std::ostream& out, benchmark::State& state) { void AddToLabel(std::ostream& out, benchmark::State& state) {
out << " writes/iteration:" out << " writes/iter:"
<< ((double)stats_.num_writes / (double)state.iterations()); << ((double)stats_.num_writes / (double)state.iterations());
} }

Loading…
Cancel
Save