#ifndef GRPC_CORE_LIB_PROFILING_TIMERS_H
#define GRPC_CORE_LIB_PROFILING_TIMERS_H
void gpr_timers_global_init(void);
void gpr_timers_global_destroy(void);
void gpr_timer_add_mark(const char* tagstr, int important, const char* file,
int line);
void gpr_timer_begin(const char* tagstr, int important, const char* file,
int line);
void gpr_timer_end(const char* tagstr, int important, const char* file,
int line);
void gpr_timers_set_log_filename(const char* filename);
void gpr_timer_set_enabled(int enabled);
#if !(defined(GRPC_STAP_PROFILER) + defined(GRPC_BASIC_PROFILER) + \
defined(GRPC_CUSTOM_PROFILER))
#define GPR_TIMER_MARK(tag, important) \
do { \
} while (0)
#define GPR_TIMER_SCOPE(tag, important) \
do { \
} while (0)
#else
#if defined(GRPC_STAP_PROFILER) && defined(GRPC_BASIC_PROFILER)
#error "GRPC_STAP_PROFILER and GRPC_BASIC_PROFILER are mutually exclusive."
#endif
#if defined(GRPC_STAP_PROFILER) && defined(GRPC_CUSTOM_PROFILER)
#error "GRPC_STAP_PROFILER and GRPC_CUSTOM_PROFILER are mutually exclusive."
#endif
#if defined(GRPC_CUSTOM_PROFILER) && defined(GRPC_BASIC_PROFILER)
#error "GRPC_CUSTOM_PROFILER and GRPC_BASIC_PROFILER are mutually exclusive."
#endif
#define GPR_TIMER_MARK(tag, important) \
gpr_timer_add_mark(tag, important, __FILE__, __LINE__);
#ifdef GRPC_STAP_PROFILER
#endif
#ifdef GRPC_BASIC_PROFILER
#endif
namespace grpc {
class ProfileScope {
public:
ProfileScope(const char* desc, bool important, const char* file, int line)
: desc_(desc) {
gpr_timer_begin(desc_, important ? 1 : 0, file, line);
}
~ProfileScope() { gpr_timer_end(desc_, 0, "n/a", 0); }
private:
const char* const desc_;
};
}
#define GPR_TIMER_SCOPE_NAME_INTERNAL(prefix, line) prefix##line
#define GPR_TIMER_SCOPE_NAME(prefix, line) \
GPR_TIMER_SCOPE_NAME_INTERNAL(prefix, line)
#define GPR_TIMER_SCOPE(tag, important) \
::grpc::ProfileScope GPR_TIMER_SCOPE_NAME(_profile_scope_, __LINE__)( \
(tag), (important), __FILE__, __LINE__)
#endif
#endif