[jboss-cvs] JBossCache/tests/perf/org/jboss/cache ...
Elias Ross
genman at noderunner.net
Tue Jan 16 20:31:08 EST 2007
User: genman
Date: 07/01/16 20:31:08
Modified: tests/perf/org/jboss/cache SizeOf.java
Log:
Restrict visibility in CacheImpl of methods and members
Revision Changes Path
1.3 +53 -50 JBossCache/tests/perf/org/jboss/cache/SizeOf.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SizeOf.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/perf/org/jboss/cache/SizeOf.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- SizeOf.java 12 Jun 2006 22:26:28 -0000 1.2
+++ SizeOf.java 17 Jan 2007 01:31:08 -0000 1.3
@@ -1,12 +1,5 @@
-
package org.jboss.cache;
-import java.util.LinkedHashMap;
-import java.util.HashMap;
-import java.util.IdentityHashMap;
-import java.util.LinkedList;
-import java.util.ArrayList;
-
/**
* Measure the size of an object by allocating a bunch of them and
* seeing how much heap memory was consumed.
@@ -14,9 +7,11 @@
* Created on Apr 8, 2003 3:59:14 PM
* @author mroth
*/
-public class SizeOf {
+public class SizeOf
+{
- public static void main(String[] argv) throws Exception {
+ public static void main(String[] argv) throws Exception
+ {
System.out.println("SizeOf: (bytes)");
for (int i = 0; i < argv.length; i++)
@@ -24,16 +19,19 @@
}
- private static void reportSize(Class s) throws Exception {
+ private static void reportSize(Class s) throws Exception
+ {
System.out.println(s + ": " + estimateSize(s));
}
- public static long estimateSize(Class s) throws Exception {
+ public static long estimateSize(Class s) throws Exception
+ {
final int n = 100000;
Object[] array = new Object[n];
giveGarbageCollectionAChance();
long before = getUsedMemory();
- for (int i = 0; i < n; i++) {
+ for (int i = 0; i < n; i++)
+ {
Object dummy = s.newInstance();
array[i] = dummy;
}
@@ -44,18 +42,23 @@
return Math.round((double) (diff) / (double) n);
}
- private static void giveGarbageCollectionAChance() {
- try {
+ private static void giveGarbageCollectionAChance()
+ {
+ try
+ {
Thread.sleep(1000);
System.gc();
Thread.sleep(1000);
System.gc();
- } catch (InterruptedException e) {
+ }
+ catch (InterruptedException e)
+ {
// ignore - should not happen
}
}
- private static long getUsedMemory() {
+ private static long getUsedMemory()
+ {
Runtime r = Runtime.getRuntime();
return r.totalMemory() - r.freeMemory();
}
More information about the jboss-cvs-commits
mailing list