diff options
author | John Wiegley <johnw@newartisans.com> | 2007-04-20 02:14:53 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:38:28 -0400 |
commit | b84f676946941df6f7e8476d77d1db0cbe7736c5 (patch) | |
tree | 9ee7c7a2d3b7496b38ad127519210adfeced2241 /timing.h | |
parent | 539370ff1b37772e9f11439f652ffd3583beeedb (diff) | |
download | fork-ledger-b84f676946941df6f7e8476d77d1db0cbe7736c5.tar.gz fork-ledger-b84f676946941df6f7e8476d77d1db0cbe7736c5.tar.bz2 fork-ledger-b84f676946941df6f7e8476d77d1db0cbe7736c5.zip |
Did some optimization and memory cleanup
Diffstat (limited to 'timing.h')
-rw-r--r-- | timing.h | 31 |
1 files changed, 17 insertions, 14 deletions
@@ -1,10 +1,10 @@ #ifndef _TIMING_H #define _TIMING_H -#include "debug.h" - #include <ctime> +#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) |