Merge pull request #15108 from ncteisen/compile-out-tracers

Compile Out Tracers
pull/14933/merge
Noah Eisen 7 years ago committed by GitHub
commit c530fe94d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/core/lib/debug/trace.h

@ -57,13 +57,22 @@ class TraceFlag {
const char* name() const { return name_; } const char* name() const { return name_; }
// This following define may be commented out to ensure that the compiler
// deletes any "if (tracer.enabled()) {...}" codeblocks. This is useful to
// test the performance impact tracers have on the system.
//
// #define COMPILE_OUT_ALL_TRACERS_IN_OPT_BUILD
#ifdef COMPILE_OUT_ALL_TRACERS_IN_OPT_BUILD
bool enabled() { return false; }
#else
bool enabled() { bool enabled() {
#ifdef GRPC_THREADSAFE_TRACER #ifdef GRPC_THREADSAFE_TRACER
return gpr_atm_no_barrier_load(&value_) != 0; return gpr_atm_no_barrier_load(&value_) != 0;
#else #else
return value_; return value_;
#endif #endif // GRPC_THREADSAFE_TRACER
} }
#endif // COMPILE_OUT_ALL_TRACERS_IN_OPT_BUILD
private: private:
friend void grpc_core::testing::grpc_tracer_enable_flag(TraceFlag* flag); friend void grpc_core::testing::grpc_tracer_enable_flag(TraceFlag* flag);

Loading…
Cancel
Save