summaryrefslogtreecommitdiff
path: root/timing.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-20 02:14:53 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:28 -0400
commitb84f676946941df6f7e8476d77d1db0cbe7736c5 (patch)
tree9ee7c7a2d3b7496b38ad127519210adfeced2241 /timing.h
parent539370ff1b37772e9f11439f652ffd3583beeedb (diff)
downloadfork-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.h31
1 files changed, 17 insertions, 14 deletions
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 <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)