commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bur...@apache.org
Subject svn commit: r156736 - in jakarta/commons/sandbox/benchmark/trunk/src: java/org/apache/commons/benchmark/Benchmark.java test/org/apache/commons/benchmark/Test1.java
Date Thu, 10 Mar 2005 03:49:46 GMT
Author: burton
Date: Wed Mar  9 19:49:44 2005
New Revision: 156736

URL: http://svn.apache.org/viewcvs?view=rev&rev=156736
Log:
unit test to assert that memory usage is within acceptable limits...

Modified:
    jakarta/commons/sandbox/benchmark/trunk/src/java/org/apache/commons/benchmark/Benchmark.java
    jakarta/commons/sandbox/benchmark/trunk/src/test/org/apache/commons/benchmark/Test1.java

Modified: jakarta/commons/sandbox/benchmark/trunk/src/java/org/apache/commons/benchmark/Benchmark.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/benchmark/trunk/src/java/org/apache/commons/benchmark/Benchmark.java?view=diff&r1=156735&r2=156736
==============================================================================
--- jakarta/commons/sandbox/benchmark/trunk/src/java/org/apache/commons/benchmark/Benchmark.java
(original)
+++ jakarta/commons/sandbox/benchmark/trunk/src/java/org/apache/commons/benchmark/Benchmark.java
Wed Mar  9 19:49:44 2005
@@ -103,7 +103,7 @@
     /**
      * Maintain a metadata map between the name and BMeta classes.
      */
-    public static HashMap benchmarks = new HashMap();
+    static HashMap benchmarks = new HashMap();
 
     /**
      * The current name of this benchmark.

Modified: jakarta/commons/sandbox/benchmark/trunk/src/test/org/apache/commons/benchmark/Test1.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/benchmark/trunk/src/test/org/apache/commons/benchmark/Test1.java?view=diff&r1=156735&r2=156736
==============================================================================
--- jakarta/commons/sandbox/benchmark/trunk/src/test/org/apache/commons/benchmark/Test1.java
(original)
+++ jakarta/commons/sandbox/benchmark/trunk/src/test/org/apache/commons/benchmark/Test1.java
Wed Mar  9 19:49:44 2005
@@ -33,6 +33,34 @@
         super(testName);
     }
 
+    //FIXME: setup a test to verify that X benchmarks don't use more than Y
+    //bytes of memory.
+
+    public void testMemory() throws Exception {
+
+        long before = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
+
+        int count = 1000;
+
+        for ( int i  = 0; i < count; ++i  ) {
+
+            Benchmark b = Benchmark.getBenchmark( "foo:" + i );
+            b.start();
+            b.complete();
+            
+        }
+
+        long after = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
+
+        //150k bytes is only 150 bytes per benchmark.  
+        assertTrue( after < 150 * count );
+        
+        System.out.println( "total bytes used: " + (after-before) );
+
+        Benchmark.benchmarks = new HashMap();
+        
+    }
+    
     /**
      * Test out all XMLRPC methods...that we have exported.
      *



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message