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:
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -78,7 +78,9 @@ main (int __attr_unused___ argc,
|
||||
|
||||
mem_register_a_try_give_memory_back_callback (test_heap_give_some_memory_back);
|
||||
|
||||
mem_heap_print ();
|
||||
#ifdef MEM_STATS
|
||||
mem_heap_stats_print ();
|
||||
#endif /* MEM_STATS */
|
||||
|
||||
for (uint32_t i = 0; i < test_iters; i++)
|
||||
{
|
||||
@@ -110,7 +112,9 @@ main (int __attr_unused___ argc,
|
||||
}
|
||||
}
|
||||
|
||||
mem_heap_print ();
|
||||
#ifdef MEM_STATS
|
||||
mem_heap_stats_print ();
|
||||
#endif /* MEM_STATS */
|
||||
|
||||
return 0;
|
||||
} /* main */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -80,22 +80,7 @@ main (int __attr_unused___ argc,
|
||||
}
|
||||
|
||||
#ifdef MEM_STATS
|
||||
mem_pools_stats_t stats;
|
||||
mem_pools_get_stats (&stats);
|
||||
|
||||
printf ("Pools stats:\n");
|
||||
printf (" Chunk size: %u\n"
|
||||
" Pools: %zu\n"
|
||||
" Allocated chunks: %zu\n"
|
||||
" Free chunks: %zu\n"
|
||||
" Peak pools: %zu\n"
|
||||
" Peak allocated chunks: %zu\n\n",
|
||||
MEM_POOL_CHUNK_SIZE,
|
||||
stats.pools_count,
|
||||
stats.allocated_chunks,
|
||||
stats.free_chunks,
|
||||
stats.peak_pools_count,
|
||||
stats.peak_allocated_chunks);
|
||||
mem_pools_stats_print ();
|
||||
#endif /* MEM_STATS */
|
||||
|
||||
mem_finalize (false);
|
||||
|
||||
Reference in New Issue
Block a user