about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-08-12 16:30:28 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-08-12 16:30:28 -0700
commit026efa5703d519eade6b08f58075b28fd789239a (patch)
treeb42c169cd7d740497880fe2a3da72fc283c02f39
parent78e3f55368cd7ca5e3ca291f18990501eac9e1ff (diff)
downloadmu-026efa5703d519eade6b08f58075b28fd789239a.tar.gz
3171 - new commandline flag: --trace
The edit/ app without tracing turned on takes 22s to load up a
reasonably complex file and run 12 scenarios. Turn on tracing, and it
takes 68s. Turn on tracing just for app-level stashes, and it still
takes 40s. That's too much overhead, so let's keep it turned off by
default but give students an option to enable it at the commandline.
-rw-r--r--020run.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/020run.cc b/020run.cc
index 72fda856..ef2833a5 100644
--- a/020run.cc
+++ b/020run.cc
@@ -169,19 +169,28 @@ if (!Run_tests && contains_key(Recipe_ordinal, "main") && contains_key(Recipe, g
   // Running Main
   setup();
 //?   Save_trace = true;
-//?   START_TRACING_UNTIL_END_OF_SCOPE;
+  if (Trace_main) Trace_stream = new trace_stream;
   trace(9990, "run") << "=== Starting to run" << end();
   assert(Num_calls_to_transform_all == 1);
   run_main(argc, argv);
+  if (Trace_main) delete Trace_stream, Trace_stream = NULL;
   teardown();
 }
-
 :(code)
 void run_main(int argc, char* argv[]) {
   recipe_ordinal r = get(Recipe_ordinal, "main");
   if (r) run(r);
 }
 
+//: By default we don't maintain the trace while running main because its
+//: overheads can grow rapidly. However, it's useful when debugging.
+:(before "End Globals")
+bool Trace_main = false;
+:(before "End Commandline Options(*arg)")
+else if (is_equal(*arg, "--trace")) {
+  Trace_main = true;
+}
+
 :(code)
 void dump_profile() {
   for (map<string, int>::iterator p = Instructions_running.begin(); p != Instructions_running.end(); ++p) {