diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-07-14 15:51:15 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-07-14 15:54:39 -0700 |
commit | 094548498bfd351d2b2f7323e7757113654dbab1 (patch) | |
tree | bdbe503ab62dbff27f9a9aebf6634977098514fe /003trace.cc | |
parent | 34c4850fa70366a4ea6a07a82f83be7c41ed9b4f (diff) | |
download | mu-094548498bfd351d2b2f7323e7757113654dbab1.tar.gz |
1782 - stop tracing anything but warnings inside edit
Speeds up edit.mu tests by 10x, and shrinks memory usage by 100x. We need a more efficient implementation of traces, but we can keep going for now. We didn't really need to reclaim memory just yet, after all. Mu is pretty memory-efficient.
Diffstat (limited to '003trace.cc')
-rw-r--r-- | 003trace.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/003trace.cc b/003trace.cc index d7b78668..11bad7a2 100644 --- a/003trace.cc +++ b/003trace.cc @@ -103,14 +103,17 @@ struct trace_stream { string curr_layer; int curr_depth; string dump_layer; + string collect_layer; // if set, ignore all other layers + ofstream null_stream; // never opens a file, so writes silently fail trace_stream() :curr_stream(NULL), curr_depth(0) {} ~trace_stream() { if (curr_stream) delete curr_stream; } - ostringstream& stream(string layer) { + ostream& stream(string layer) { return stream(0, layer); } - ostringstream& stream(int depth, string layer) { + ostream& stream(int depth, string layer) { + if (!collect_layer.empty() && layer != collect_layer) return null_stream; newline(); curr_stream = new ostringstream; curr_layer = layer; @@ -154,7 +157,6 @@ trace_stream* Trace_stream = NULL; // Top-level helper. IMPORTANT: can't nest. #define trace(...) !Trace_stream ? cerr /*print nothing*/ : Trace_stream->stream(__VA_ARGS__) -//? #define trace(...) true ? cerr /*print nothing*/ : Trace_stream->stream(__VA_ARGS__) // Warnings should go straight to cerr by default since calls to trace() have // some unfriendly constraints (they delay printing, they can't nest) #define raise ((!Trace_stream || !Hide_warnings) ? (tb_shutdown(),cerr) /*do print*/ : Trace_stream->stream("warn")) |