Refactor the printing of memory usage statistics

Make the internal heap and pools memory usage statistics APIs more
similar: how the print functions are named, where they are
implemented, and which parts of them are guarded by `MEM_STATS`.
Also, adapt unit tests to the changes.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
Akos Kiss
2016-03-11 00:12:22 +01:00
parent 011dacd1a7
commit 66c94b7d9b
7 changed files with 64 additions and 70 deletions
+20
View File
@@ -217,6 +217,26 @@ mem_pools_stats_reset_peak (void)
mem_pools_stats.peak_pools_count = mem_pools_stats.pools_count;
} /* mem_pools_stats_reset_peak */
/**
* Print pools memory usage statistics
*/
void
mem_pools_stats_print (void)
{
printf ("Pools stats:\n"
" Chunk size: %zu\n"
" Pool chunks: %zu\n"
" Peak pool chunks: %zu\n"
" Free chunks: %zu\n"
" Pool reuse ratio: %zu.%04zu\n",
MEM_POOL_CHUNK_SIZE,
mem_pools_stats.pools_count,
mem_pools_stats.peak_pools_count,
mem_pools_stats.free_chunks,
mem_pools_stats.reused_count / mem_pools_stats.new_alloc_count,
mem_pools_stats.reused_count % mem_pools_stats.new_alloc_count * 10000 / mem_pools_stats.new_alloc_count);
} /* mem_pools_stats_print */
/**
* Initalize pools' memory usage statistics account structure
*/