about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-07-10 12:58:17 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-07-10 12:58:17 -0700
commit1164aefc36a5f86d75625bcd096fac3b81043ea2 (patch)
treeccf0fc7fe78762f8b3aa6d29f43274c5b53e4077
parent032b21128012698ad4f601a6520f08e8f48ebccf (diff)
downloadmu-1164aefc36a5f86d75625bcd096fac3b81043ea2.tar.gz
1749 - investigating yesterday's sluggishness
Comparing trace counts for a single test before and after yesterday's
changes, one obvious culprit is that print-character has blown up from
754 trace lines (at all levels) to 2554.
-rw-r--r--080trace_browser.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/080trace_browser.cc b/080trace_browser.cc
index 931a9d86..121a8529 100644
--- a/080trace_browser.cc
+++ b/080trace_browser.cc
@@ -175,6 +175,13 @@ void render() {
     trace_line& curr_line = Trace_stream->past_lines.at(Trace_index[screen_row]);
     ostringstream out;
     out << std::setw(4) << curr_line.depth << ' ' << curr_line.label << ": " << curr_line.contents;
+    if (screen_row < tb_height()-1) {
+      long long int delta = lines_hidden(screen_row);
+      // home-brew escape sequence for red
+      if (delta > 999) out << "{";
+      out << " (" << lines_hidden(screen_row) << ")";
+      if (delta > 999) out << "}";
+    }
     render_line(screen_row, out.str());
   }
   // clear rest of screen
@@ -187,12 +194,24 @@ void render() {
   tb_present();
 }
 
+long long int lines_hidden(long long int screen_row) {
+  assert(Trace_index.find(screen_row) != Trace_index.end());
+  if (Trace_index.find(screen_row+1) == Trace_index.end())
+    return SIZE(Trace_stream->past_lines)-Trace_index[screen_row];
+  else
+    return Trace_index[screen_row+1] - Trace_index[screen_row];
+}
+
 void render_line(int screen_row, const string& s) {
   long long int col = 0;
+  int color = TB_WHITE;
   for (col = 0; col < tb_width() && col < SIZE(s); ++col) {
-    char c = s.at(col);
+    char c = s.at(col);  // todo: unicode
     if (c == '\n') c = ';';  // replace newlines with semi-colons
-    tb_change_cell(col, screen_row, c, TB_WHITE, TB_BLACK);
+    // escapes. hack: can't start a line with them.
+    if (c == '{') { color = /*red*/1; c = ' '; }
+    if (c == '}') { color = TB_WHITE; c = ' '; }
+    tb_change_cell(col, screen_row, c, color, TB_BLACK);
   }
   for (; col < tb_width(); ++col) {
     tb_change_cell(col, screen_row, ' ', TB_WHITE, TB_BLACK);