--- libelwix/src/mem.c 2015/06/25 00:36:48 1.4.18.1 +++ libelwix/src/mem.c 2015/06/25 01:19:09 1.4.18.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: mem.c,v 1.4.18.1 2015/06/25 00:36:48 misho Exp $ +* $Id: mem.c,v 1.4.18.2 2015/06/25 01:19:09 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -746,3 +746,45 @@ mpool_xstatistics(mpool_stat_cb cb) { mpool_statistics(elwix_mpool, cb); } + +static void +xdump_show(u_int size, u_int act, u_int inact) +{ + if (!act && !inact) + return; /* skip empty bucket */ + + if (size < 1024) + printf("\t\t* BUCKET %uB size, %u active, %u inactive\n", + size, act, inact); + else if (size < 1048576) + printf("\t\t* BUCKET %uKB size, %u active, %u inactive\n", + size / 1024, act, inact); + else + printf("\t\t* BUCKET %uMB size, %u active, %u inactive\n", + size / 1048576, act, inact); +} + +/* + * mpool_xdump() - Dump elwix memory pool statistics + * + * return: none + */ +void +mpool_xdump() +{ + printf("\n%s(%d)\n------------------------------------------------------------\n", + __func__, __LINE__); + printf( " ELWIX memory pool ::\n" + "\t- quotas Current/Max = %lu/%lu\n" + "\t- calls Alloc/Free/Cache = %lu/%lu/%lu\n" + "\t- bytes Alloc/Free/Cache = %lu/%lu/%lu\n" + "\t- buckets :\n", + elwix_mpool->pool_quota.curr, elwix_mpool->pool_quota.max, + elwix_mpool->pool_calls.alloc, elwix_mpool->pool_calls.free, + elwix_mpool->pool_calls.cache, elwix_mpool->pool_bytes.alloc, + elwix_mpool->pool_bytes.free, elwix_mpool->pool_bytes.cache); + + mpool_statistics(elwix_mpool, xdump_show); + printf("------------------------------------------------------------\n"); +} +