diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-07-14 15:11:42 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-07-14 15:13:12 -0700 |
commit | 34c4850fa70366a4ea6a07a82f83be7c41ed9b4f (patch) | |
tree | c703d25079a06e90df3ba1169514de5ff4939957 | |
parent | 77d5b5d658830bd24724f945e0d6ddf6a06adc0e (diff) | |
download | mu-34c4850fa70366a4ea6a07a82f83be7c41ed9b4f.tar.gz |
1781 - the hog is Trace_stream, not Memory
I keep forgetting about it. Until, that is, I run gprof. Even if I think I need a memory profile, a cpu profile is a pretty good proxy.
-rw-r--r-- | 003trace.cc | 1 | ||||
-rw-r--r-- | 043new.cc | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/003trace.cc b/003trace.cc index 97a00b1c..d7b78668 100644 --- a/003trace.cc +++ b/003trace.cc @@ -154,6 +154,7 @@ trace_stream* Trace_stream = NULL; // Top-level helper. IMPORTANT: can't nest. #define trace(...) !Trace_stream ? cerr /*print nothing*/ : Trace_stream->stream(__VA_ARGS__) +//? #define trace(...) true ? cerr /*print nothing*/ : Trace_stream->stream(__VA_ARGS__) // Warnings should go straight to cerr by default since calls to trace() have // some unfriendly constraints (they delay printing, they can't nest) #define raise ((!Trace_stream || !Hide_warnings) ? (tb_shutdown(),cerr) /*do print*/ : Trace_stream->stream("warn")) diff --git a/043new.cc b/043new.cc index feb4c0cf..bd5dd7bf 100644 --- a/043new.cc +++ b/043new.cc @@ -75,6 +75,8 @@ case NEW: { size = size_of(type); } } +//? Total_alloc += size; //? 1 +//? Num_alloc++; //? 1 // compute the region of memory to return // really crappy at the moment ensure_space(size); @@ -98,6 +100,18 @@ case NEW: { break; } +//? :(before "End Globals") //? 1 +//? long long int Total_alloc = 0; //? 1 +//? long long int Num_alloc = 0; //? 1 +//? long long int Total_free = 0; //? 1 +//? long long int Num_free = 0; //? 1 +//? :(before "End Setup") //? 1 +//? Total_alloc = Num_alloc = Total_free = Num_free = 0; //? 1 +//? :(before "End Teardown") //? 1 +//? cerr << Total_alloc << "/" << Num_alloc //? 1 +//? << " vs " << Total_free << "/" << Num_free << '\n'; //? 1 +//? cerr << Memory.size() << '\n'; //? 1 + :(code) void ensure_space(long long int size) { assert(size <= Initial_memory_per_routine); @@ -211,6 +225,8 @@ case ABANDON: { :(code) void abandon(long long int address, long long int size) { +//? Total_free += size; //? 1 +//? Num_free++; //? 1 //? cerr << "abandon: " << size << '\n'; //? 2 // clear memory for (long long int curr = address; curr < address+size; ++curr) @@ -299,6 +315,8 @@ long long int new_string(const string& contents) { // allocate an array just large enough for it long long int string_length = unicode_length(contents); //? cout << "string_length is " << string_length << '\n'; //? 1 +//? Total_alloc += string_length+1; //? 1 +//? Num_alloc++; //? 1 ensure_space(string_length+1); // don't forget the extra location for array size // initialize string //? cout << "new string literal: " << current_instruction().ingredients.at(0).name << '\n'; //? 1 |