Commit 2588a25f authored by Michael Arntzenius's avatar Michael Arntzenius

enable disabling Timers

parent a8bd855c
...@@ -41,6 +41,8 @@ uint64_t getCPUTicks() { ...@@ -41,6 +41,8 @@ uint64_t getCPUTicks() {
return rdtsc(); return rdtsc();
} }
#if !DISABLE_TIMERS
int Timer::level = 0; int Timer::level = 0;
Timer::Timer(long min_usec) : min_usec(min_usec), ended(true) { Timer::Timer(long min_usec) : min_usec(min_usec), ended(true) {
...@@ -104,6 +106,8 @@ Timer::~Timer() { ...@@ -104,6 +106,8 @@ Timer::~Timer() {
} }
} }
#endif // !DISABLE_TIMERS
bool startswith(const std::string& s, const std::string& pattern) { bool startswith(const std::string& s, const std::string& pattern) {
if (pattern.size() > s.size()) if (pattern.size() > s.size())
return false; return false;
......
...@@ -26,6 +26,9 @@ namespace pyston { ...@@ -26,6 +26,9 @@ namespace pyston {
uint64_t getCPUTicks(); uint64_t getCPUTicks();
#define DISABLE_TIMERS 0
#if !DISABLE_TIMERS
class Timer { class Timer {
private: private:
static int level; static int level;
...@@ -58,6 +61,23 @@ public: ...@@ -58,6 +61,23 @@ public:
uint64_t getStartTime() const { return start_time; } uint64_t getStartTime() const { return start_time; }
}; };
#else // DISABLE_TIMERS
class Timer {
public:
Timer(const char* desc = NULL, long min_usec = -1) {}
Timer(long min_usec) {}
void setExitCallback(std::function<void(uint64_t)> _exit_callback) {}
void restart(const char* newdesc, long new_min_usec) {}
void restart(const char* newdesc = NULL) {}
long end() { return 0; }
long split(const char* newdesc = NULL) { return 0; }
};
#endif // #else DISABLE_TIMERS
bool startswith(const std::string& s, const std::string& pattern); bool startswith(const std::string& s, const std::string& pattern);
bool endswith(const std::string& s, const std::string& pattern); bool endswith(const std::string& s, const std::string& pattern);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment