diff options
Diffstat (limited to 'libs/ardour/ardour/cycle_timer.h')
-rw-r--r-- | libs/ardour/ardour/cycle_timer.h | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/libs/ardour/ardour/cycle_timer.h b/libs/ardour/ardour/cycle_timer.h index 146b393a63..dc70204e82 100644 --- a/libs/ardour/ardour/cycle_timer.h +++ b/libs/ardour/ardour/cycle_timer.h @@ -24,24 +24,37 @@ #include <iostream> #include "ardour/cycles.h" +#include "ardour/debug.h" class CycleTimer { private: static float cycles_per_usec; +#ifndef NDEBUG cycles_t _entry; cycles_t _exit; std::string _name; +#endif public: - CycleTimer(std::string name) : _name (name){ - if (cycles_per_usec == 0) { - cycles_per_usec = get_mhz (); + CycleTimer(const std::string& name) { +#ifndef NDEBUG + if (PBD::debug_bits & PBD::DEBUG::CycleTimers) { + _name = name; + if (cycles_per_usec == 0) { + cycles_per_usec = get_mhz (); + } + _entry = get_cycles(); } - _entry = get_cycles(); +#endif } + ~CycleTimer() { - _exit = get_cycles(); - std::cerr << _name << ": " << (float) (_exit - _entry) / cycles_per_usec << " (" << _entry << ", " << _exit << ')' << std::endl; +#ifndef NDEBUG + if (PBD::debug_bits & PBD::DEBUG::CycleTimers) { + _exit = get_cycles(); + std::cerr << _name << ": " << (float) (_exit - _entry) / cycles_per_usec << " (" << _entry << ", " << _exit << ')' << std::endl; + } +#endif } static float get_mhz (); |