File tree Expand file tree Collapse file tree 4 files changed +13
-1
lines changed
Expand file tree Collapse file tree 4 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -193,7 +193,8 @@ static const unsigned char KEYBOARD_ASCII_MAPH_OTHERS[] = {
193193 KEYBOARD_SC_RPF0_keypad_minus , '-' ,
194194 KEYBOARD_SC_RPF0_keypad_mul , '*' ,
195195 KEYBOARD_SC_RPF0_keypad_plus , '+' ,
196- KEYBOARD_SC_PE0_RPF0_keypad_enter , '\n'
196+ KEYBOARD_SC_PE0_RPF0_keypad_enter , '\n' ,
197+ KEYBOARD_SC_RPF0_backspace , '\b'
197198};
198199
199200static unsigned char KEYBOARD_ASCII_MAPPING [256 ];
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ int min(int, int);
1818int max (int , int );
1919int abs (int a);
2020
21+ int benchmark_get_heap_usage ();
2122void * malloc (size_t size);
2223void free (void * ptr);
2324
Original file line number Diff line number Diff line change @@ -148,6 +148,13 @@ extern char _heap_start[]; // defined in linker.ld
148148static int heap_head_offset = 0 ;
149149static const int heap_stack_safety_gap = 1024 ; // keep 1 kb free between stack and heap
150150
151+ // benchmarking
152+ static int benchmark_heap_inuse = 0 ;
153+
154+ int benchmark_get_heap_usage () {
155+ return benchmark_heap_inuse ;
156+ }
157+
151158void * malloc (size_t size ) {
152159 void * loc = _heap_start + heap_head_offset ;
153160 void * max_loc = get_current_esp ()- heap_stack_safety_gap - size ;
@@ -157,6 +164,7 @@ void* malloc(size_t size) {
157164 return NULL ;
158165 }
159166 heap_head_offset += size ;
167+ benchmark_heap_inuse += size ;
160168 return loc ;
161169}
162170
Original file line number Diff line number Diff line change @@ -407,6 +407,8 @@ void start_logo() {
407407void cleanup_graphics () {
408408 std::graphics::closegraph ();
409409 std::cout << " logo graphics closed" << std::endl;
410+ std::cout << " heap memory at exit " <<
411+ (std::benchmark_get_heap_usage ()/1024 ) << " KB" << std::endl;
410412}
411413
412414int show_usage () {
You can’t perform that action at this time.
0 commit comments