about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--020run.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/020run.cc b/020run.cc
index e9d8c2a8..1c63c564 100644
--- a/020run.cc
+++ b/020run.cc
@@ -44,6 +44,7 @@ struct routine {
 
 :(before "End Globals")
 routine* Current_routine = NULL;
+map<string, long long int> Instructions_running;
 
 :(code)
 void run(recipe_ordinal r) {
@@ -57,6 +58,7 @@ void run_current_routine()
   while (!Current_routine->completed())  // later layers will modify condition
   {
     // Running One Instruction
+    Instructions_running[current_recipe_name()]++;
     if (current_instruction().is_label) { ++current_step_index(); continue; }
     trace(Initial_callstack_depth+Callstack_depth, "run") << current_instruction().to_string() << end();
     if (Memory[0] != 0) {
@@ -154,6 +156,15 @@ if (!Run_tests) {
 }
 
 :(code)
+void dump_profile() {
+  for (map<string, long long int>::iterator p = Instructions_running.begin(); p != Instructions_running.end(); ++p) {
+    cerr << p->first << ": " << p->second << '\n';
+  }
+}
+:(before "End One-time Setup")
+atexit(dump_profile);
+
+:(code)
 void cleanup_main() {
   if (!Trace_file.empty() && Trace_stream) {
     ofstream fout(Trace_file.c_str());