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 <fdum...@jnode.org>

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.


------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Jnode-svn-commits mailing list
Jnode-svn-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jnode-svn-commits

Reply via email to