From 3886b9c62370ac9dd12f1613cdb20b93e71d7f04 Mon Sep 17 00:00:00 2001 From: Ian Piumarta Date: Tue, 1 Sep 2020 18:11:15 +0900 Subject: [PATCH] Print the amount of memory allocated using k/M/G bytes --- parse.leg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parse.leg b/parse.leg index 21f7f21..7e7d10b 100644 --- a/parse.leg +++ b/parse.leg @@ -1988,7 +1988,10 @@ int main(int argc, char **argv) readEvalPrint(globals, NULL); } - printf("[GC: %lli bytes allocated]\n", nalloc); + if (nalloc < 1024) printf("[GC: %lli bytes allocated]\n", nalloc ); + else if (nalloc < 1024*1024) printf("[GC: %lli kB allocated]\n", nalloc / 1024 ); + else if (nalloc < 1024*1024*1024) printf("[GC: %.2f MB allocated]\n", (double)nalloc / ( 1024*1024)); + else printf("[GC: %.2f GB allocated]\n", (double)nalloc / (1024*1024*1024)); return 0;