Changeset 6d611fb for src/Common
- Timestamp:
- May 3, 2018, 5:02:05 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- 01690b7
- Parents:
- c9d5c4f
- Location:
- src/Common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/Heap.cc
rc9d5c4f r6d611fb 14 14 // 15 15 16 namespace HeapStats{ 17 void newPass( const char * const name ) {} 18 void printStats() {} 16 #include <cstddef> 17 #include <cassert> 18 #include <iomanip> 19 #include <iostream> 20 21 namespace HeapStats { 22 #if !defined( WITH_HEAP_STATISTICS ) 23 void newPass( const char * const ) {} 24 25 void printStats() {} 26 #else 27 struct StatBlock { 28 const char * name = nullptr; 29 size_t mallocs = 0; 30 size_t frees = 0; 31 }; 32 33 StatBlock passes[100]; 34 const size_t passes_size = sizeof(passes) / sizeof(passes[0]); 35 size_t passes_cnt = 0; 36 37 void newPass( const char * const name ) { 38 passes[passes_cnt].name = name; 39 passes[passes_cnt].mallocs = 0; 40 passes[passes_cnt].frees = 0; 41 passes_cnt++; 42 43 assertf(passes_cnt < passes_size, "Too many passes for HeapStats, increase the size of the array in Heap.h"); 44 } 45 46 void printStats() { 47 std::cerr << "Heap usage statistic:" << std::endl; 48 std::cerr << "Pass | Malloc Count | Free Count" << std::endl; 49 for(size_t i = 0; i < passes_cnt; i++) { 50 std::cerr << std::setw(20) << passes[i].name << " | "; 51 std::cerr << std::setw(12) << passes[i].mallocs << " | "; 52 std::cerr << std::setw(12) << passes[i].frees << "\n"; 53 } 54 } 55 #endif 19 56 } 20 57 -
src/Common/Heap.h
rc9d5c4f r6d611fb 17 17 18 18 namespace HeapStats { 19 20 19 void newPass( const char * const name ); 20 void printStats(); 21 21 }
Note: See TracChangeset
for help on using the changeset viewer.