From e0551d78f10b9405f30d3074f3644c4de075d317 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 14 Aug 2015 18:30:46 -0700 Subject: 1995 - simple profile of instruction spend The slowness of the environment -- even for code spanning just a couple hundred lines -- is the biggest priority right now. --- 020run.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to '020run.cc') 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 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) { @@ -153,6 +155,15 @@ if (!Run_tests) { teardown(); } +:(code) +void dump_profile() { + for (map::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) { -- cgit 1.4.1-2-gfad0