Commits

Anonymous committed a090673

Full C++ version of basic binlog

  • Participants
  • Parent commits cfe636a

Comments (0)

Files changed (1)

 #include <vector>
 
 #include "tracevis.h"
+#include "tracevis_gen.h"
 
+const double CPU_SPEED = 2.2e9;
 typedef unsigned long long uint64;
 
 const char* filename = "/tmp/jsacts";
 const size_t pagesize = 4096;
 const unsigned page_records = pagesize/sizeof(uint64);
 
+static void rep(char ch, int n)
+{
+  for (int i = 0; i < n; ++i)
+    putchar(ch);
+  putchar('\n');
+}
+
 class Record
 {
 public:
   }
 
   void list_summary() const {
-    for (int i = 0; i < S_COUNT; ++i) {
-      printf("%2d  %llu %f\n", i, state_summary[i], state_summary[i] / 2.2e9);
+    uint64 subtotal = 0;
+    for (int i = 1; i < S_COUNT; ++i) {
+      subtotal += state_summary[i];
+      printf("%-12s %12.6f\n", state_names[i], state_summary[i] / CPU_SPEED * 1000);
     }
+    rep('-', 25);
+    printf("%-12s %12.6f\n", "Subtotal", subtotal / CPU_SPEED * 1000);
+    printf("%-12s %12.6f\n", "Non-JS", state_summary[0] / CPU_SPEED * 1000);
+    rep('=', 25);
+    printf("%-12s %12.6f\n", "Total", (state_summary[0]+subtotal) / CPU_SPEED * 1000);
   }
 };