final StringBuilder sb = new StringBuilder();
for( int p = 0, pLimit = node.pathlength(); p < pLimit; ++p )
sb.append( " " );
final IObjectProfileNode root = node.root();
final IObjectProfileNode[] children = node.children();
double sizeInMB = ProfileUtils.mb( node.size() );
sb.append( String.format( "%.2f", sizeInMB ) );
if( node != root ) // root node is always 100% of the overall size
{
double percent = (double) node.size() / root.size();
if( percent <= memPercentageLimit )
return;
sb.append( " (" );
sb.append( String.format( "%2.1f%%", 100 * percent ) );
sb.append( ")" );
}
sb.append( " -> " );
String name = node.name();
final int lastDot = name.lastIndexOf( '.' );
if( lastDot >= 0 )
name = name.substring( lastDot + 1 );
sb.append( name );
if( node.object() != null ) // skip shell pseudo-nodes
{
if( node.name().endsWith( "#table" ) || node.name().endsWith( "#elementData" ) ) {
IObjectProfileNode shell = null;
int n = children.length - 1;
for( int i = n; i >= 0; i-- ) {
shell = children[i];
if( shell.object() == null )
break;
}
int size = node.size() - shell.size();
double avg = (double) size / n;
sb.append( " children: " + n + " avg: " + avg + " " + shell.name() + " "
+ ProfileUtils.mb( shell.size() ) );
}
else {
sb.append( " : " );
sb.append( ObjectProfiler.typeName( node.object().getClass(), true ) );