aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/microbenchmarks/helpers.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/cpp/microbenchmarks/helpers.cc')
-rw-r--r--test/cpp/microbenchmarks/helpers.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/test/cpp/microbenchmarks/helpers.cc b/test/cpp/microbenchmarks/helpers.cc
index 947e81ffd8..d277c5984c 100644
--- a/test/cpp/microbenchmarks/helpers.cc
+++ b/test/cpp/microbenchmarks/helpers.cc
@@ -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
}