Dont use memory counters unless counters mode is on

pull/10067/head
Craig Tiller 8 years ago
parent 5ea6c9f364
commit 71c286466a
  1. 8
      test/cpp/microbenchmarks/helpers.cc
  2. 2
      test/cpp/microbenchmarks/helpers.h

@ -45,6 +45,7 @@ void TrackCounters::Finish(benchmark::State &state) {
void TrackCounters::AddToLabel(std::ostream &out, benchmark::State &state) {
#ifdef GPR_LOW_LEVEL_COUNTERS
grpc_memory_counters counters_at_end = grpc_memory_counters_snapshot();
out << " locks/iter:" << ((double)(gpr_atm_no_barrier_load(&gpr_mu_locks) -
mu_locks_at_start_) /
(double)state.iterations())
@ -55,11 +56,10 @@ void TrackCounters::AddToLabel(std::ostream &out, benchmark::State &state) {
<< " atm_add/iter:"
<< ((double)(gpr_atm_no_barrier_load(&gpr_counter_atm_add) -
atm_add_at_start_) /
(double)state.iterations());
#endif
grpc_memory_counters counters_at_end = grpc_memory_counters_snapshot();
out << " allocs/iter:"
(double)state.iterations())
<< " allocs/iter:"
<< ((double)(counters_at_end.total_allocs_absolute -
counters_at_start_.total_allocs_absolute) /
(double)state.iterations());
#endif
}

@ -84,8 +84,8 @@ class TrackCounters {
gpr_atm_no_barrier_load(&gpr_counter_atm_cas);
const size_t atm_add_at_start_ =
gpr_atm_no_barrier_load(&gpr_counter_atm_add);
#endif
grpc_memory_counters counters_at_start_ = grpc_memory_counters_snapshot();
#endif
};
#endif

Loading…
Cancel
Save