6 #ifndef TURI_UTIL_TRACEPOINT_HPP 7 #define TURI_UTIL_TRACEPOINT_HPP 11 #include <timer/timer.hpp> 12 #include <core/util/branch_hints.hpp> 13 #include <core/parallel/atomic.hpp> 14 #include <core/parallel/atomic_ops.hpp> 51 std::string description;
52 bool print_on_destruct;
53 turi::atomic<unsigned long long> count;
54 turi::atomic<unsigned long long> total;
55 unsigned long long minimum;
56 unsigned long long maximum;
58 std::string description =
"",
59 bool print_on_destruct =
true):
61 description(description),
62 print_on_destruct(print_on_destruct),
65 minimum(std::numeric_limits<unsigned long long>::max()),
74 bool print_out =
true) {
77 print_on_destruct = print_out;
83 inline void incorporate(
unsigned long long val) __attribute__((always_inline)) {
87 unsigned long long m = minimum;
91 unsigned long long m = maximum;
100 count.inc(val.count.value);
101 total.inc(val.total.value);
103 unsigned long long m = minimum;
107 unsigned long long m = maximum;
129 void print(std::ostream& out,
unsigned long long tpersec = 0)
const;
221 #ifdef DOXYGEN_DOCUMENTATION 222 #define USE_TRACEPOINT 224 #ifdef USE_TRACEPOINT 225 #define DECLARE_TRACER(name) turi::trace_count name; 227 #define INITIALIZE_TRACER(name, description) name.initialize(#name, description); 228 #define INITIALIZE_TRACER_NO_PRINT(name, description) name.initialize(#name, description, false); 230 #define BEGIN_TRACEPOINT(name) unsigned long long __ ## name ## _trace_ = rdtsc(); 231 #define END_TRACEPOINT(name) name.incorporate(rdtsc() - __ ## name ## _trace_); 232 #define END_AND_BEGIN_TRACEPOINT(endname, beginname) unsigned long long __ ## beginname ## _trace_ = rdtsc(); \ 233 endname.incorporate(__ ## beginname ## _trace_ - __ ## endname ## _trace_); 235 #define DECLARE_TRACER(name) 236 #define INITIALIZE_TRACER(name, description) 237 #define INITIALIZE_TRACER_NO_PRINT(name, description) 239 #define BEGIN_TRACEPOINT(name) 240 #define END_TRACEPOINT(name) 241 #define END_AND_BEGIN_TRACEPOINT(endname, beginname) void incorporate(unsigned long long val) __attribute__((always_inline))
void incorporate(const trace_count &val) __attribute__((always_inline))
void print(std::ostream &out, unsigned long long tpersec=0) const
bool atomic_compare_and_swap(T &a, T oldval, T newval)
void initialize(std::string n, std::string desc, bool print_out=true)
trace_count & operator+=(trace_count &val)