From: <fd...@us...> - 2009-08-16 09:50:51
|
Revision: 5648 http://jnode.svn.sourceforge.net/jnode/?rev=5648&view=rev Author: fduminy Date: 2009-08-16 09:50:44 +0000 (Sun, 16 Aug 2009) Log Message: ----------- restored toString method Modified Paths: -------------- trunk/core/src/core/org/jnode/vm/memmgr/def/DefHeapStatistics.java Modified: trunk/core/src/core/org/jnode/vm/memmgr/def/DefHeapStatistics.java =================================================================== --- trunk/core/src/core/org/jnode/vm/memmgr/def/DefHeapStatistics.java 2009-08-15 20:05:41 UTC (rev 5647) +++ trunk/core/src/core/org/jnode/vm/memmgr/def/DefHeapStatistics.java 2009-08-16 09:50:44 UTC (rev 5648) @@ -94,6 +94,20 @@ } } + /** + * {@inheritDoc} + */ + public String toString() { + final StringBuilder sb = new StringBuilder(); + try { + writeTo(sb); + } catch (IOException e) { + // normally, it will never happen + throw new RuntimeException(e); + } + return sb.toString(); + } + static final class HeapCounter { private final String name; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2011-08-24 18:26:22
|
Revision: 5860 http://jnode.svn.sourceforge.net/jnode/?rev=5860&view=rev Author: fduminy Date: 2011-08-24 18:26:16 +0000 (Wed, 24 Aug 2011) Log Message: ----------- fixed missing newline after last line Signed-off-by: Fabien DUMINY <fd...@jn...> Modified Paths: -------------- trunk/core/src/core/org/jnode/vm/memmgr/def/DefHeapStatistics.java Modified: trunk/core/src/core/org/jnode/vm/memmgr/def/DefHeapStatistics.java =================================================================== --- trunk/core/src/core/org/jnode/vm/memmgr/def/DefHeapStatistics.java 2011-08-24 18:25:50 UTC (rev 5859) +++ trunk/core/src/core/org/jnode/vm/memmgr/def/DefHeapStatistics.java 2011-08-24 18:26:16 UTC (rev 5860) @@ -93,6 +93,7 @@ c.append(a); } } + a.append(newline); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2011-08-24 18:28:38
|
Revision: 5863 http://jnode.svn.sourceforge.net/jnode/?rev=5863&view=rev Author: fduminy Date: 2011-08-24 18:28:32 +0000 (Wed, 24 Aug 2011) Log Message: ----------- added summary for the object list Signed-off-by: Fabien DUMINY <fd...@jn...> Modified Paths: -------------- trunk/core/src/core/org/jnode/vm/memmgr/def/DefHeapStatistics.java Modified: trunk/core/src/core/org/jnode/vm/memmgr/def/DefHeapStatistics.java =================================================================== --- trunk/core/src/core/org/jnode/vm/memmgr/def/DefHeapStatistics.java 2011-08-24 18:28:04 UTC (rev 5862) +++ trunk/core/src/core/org/jnode/vm/memmgr/def/DefHeapStatistics.java 2011-08-24 18:28:32 UTC (rev 5863) @@ -43,6 +43,9 @@ private static final char NEWLINE = '\n'; private static final String USAGE = " memory usage="; private static final String NO_MATCHING_OBJECT = "No object is matching criteria"; + private static final String SUMMARY = "Summary : "; + private static final String CLASSES = " classe(s) "; + private static final String INSTANCES = " instances(s) "; public boolean contains(String classname) { // If we don't accept this class, we pretend to have it already to (maybe) avoid unnecessary work @@ -101,6 +104,10 @@ if (countData.isEmpty()) { a.append(NO_MATCHING_OBJECT); } else { + int nbClasses = 0; + int nbInstances = 0; + int totalSize = 0; + for (HeapCounter c : countData.values()) { if ((c.getInstanceCount() >= minInstanceCount) && (c.getTotalSize() >= minTotalSize)) { if (first) { @@ -109,12 +116,36 @@ a.append(NEWLINE); } c.append(a); + + nbClasses++; + nbInstances += c.getInstanceCount(); + totalSize += c.getTotalSize(); } } + + if (nbClasses == 0) { + a.append(NO_MATCHING_OBJECT); + } else { + a.append(NEWLINE); + a.append(SUMMARY).append(Integer.toString(nbClasses)).append(CLASSES); + a.append(Integer.toString(nbInstances)).append(INSTANCES); + appendUsage(a, totalSize); + } } a.append(NEWLINE); } + private static void appendUsage(Appendable a, long size) throws IOException { + a.append(USAGE); + if (size >= 1024) { + a.append(NumberUtils.toBinaryByte(size)).append(" ("); + a.append(Long.toString(size)).append("b)"); + } else { + a.append(Long.toString(size)).append('b'); + } + + } + /** * {@inheritDoc} */ @@ -163,14 +194,7 @@ a.append(Integer.toString(instanceCount)); if (objectSize != 0) { - a.append(USAGE); - long size = getTotalSize(); - if (size >= 1024) { - a.append(NumberUtils.toBinaryByte(size)).append(" ("); - a.append(Long.toString(size)).append("b)"); - } else { - a.append(Long.toString(size)).append('b'); - } + appendUsage(a, getTotalSize()); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |