From b84f676946941df6f7e8476d77d1db0cbe7736c5 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 20 Apr 2007 02:14:53 +0000 Subject: Did some optimization and memory cleanup --- timing.h | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'timing.h') diff --git a/timing.h b/timing.h index 7e1029ea..30257a04 100644 --- a/timing.h +++ b/timing.h @@ -1,10 +1,10 @@ #ifndef _TIMING_H #define _TIMING_H -#include "debug.h" - #include +#include "trace.h" + namespace ledger { class timing_t @@ -12,26 +12,29 @@ class timing_t public: std::clock_t begin; std::clock_t cumulative; - std::string file; + string file; unsigned long line; - std::string symbol; - std::string category; + string symbol; + string category; - timing_t(const std::string& _symbol, const std::string& _category) + timing_t(const string& _symbol, const string& _category) : begin(0), cumulative(0), symbol(_symbol), category(_category) {} - timing_t(const std::string& _symbol) + timing_t(const string& _symbol) : begin(0), cumulative(0), symbol(_symbol) {} ~timing_t() { - std::string cls = "timing.results."; + string cls = "timing.results."; cls += symbol; +#if 0 + // jww (2007-04-19): This crashes things nowadays DEBUG_PRINT(cls.c_str(), file << ":" << line << ": " << category << " = " << (double(cumulative) / double(CLOCKS_PER_SEC)) << "s"); +#endif } - void start(const std::string& _file, unsigned long _line) { + void start(const string& _file, unsigned long _line) { file = _file; line = _line; begin = std::clock(); @@ -45,11 +48,11 @@ class timing_t } }; -#ifdef DEBUG_ENABLED -#define TIMER_DEF(sym, cat) static timing_t sym(#sym, cat) -#define TIMER_DEF_(sym) static timing_t sym(#sym, #sym) -#define TIMER_START(sym) sym.start(__FILE__, __LINE__) -#define TIMER_STOP(sym) sym.stop() +#if DEBUG_LEVEL >= 4 +#define TIMER_DEF(sym, cat) static timing_t sym(#sym, cat); +#define TIMER_DEF_(sym) static timing_t sym(#sym, #sym); +#define TIMER_START(sym) sym.start(__FILE__, __LINE__); +#define TIMER_STOP(sym) sym.stop(); #else #define TIMER_DEF(sym, cat) #define TIMER_DEF_(sym) -- cgit v1.2.3