commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bur...@apache.org
Subject svn commit: r156744 - 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 05:58:37 GMT
Author: burton
Date: Wed Mar  9 21:58:34 2005
New Revision: 156744

URL: http://svn.apache.org/viewcvs?view=rev&rev=156744
Log:
...

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=156743&r2=156744
==============================================================================
--- 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 21:58:34 2005
@@ -260,6 +260,21 @@
     }
 
     /**
+     * Create a benchmark on a the caller when performing a specific operation
+     * on a given target object..  For example if your class is 'org.apache.Foo'
+     * and the operation is 'bar' then the resulting benchmark name will be
+     * 'org.apache.Foo#bar'.
+     */
+    public static Benchmark getBenchmark( Object target,
+                                          String operation ) {
+
+        String name = target.getClass().getName() + "#" + operation;
+
+        return getBenchmark( name );
+        
+    }
+    
+    /**
      * Factory method for obtaining a benchmark by name
      *
      */

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=156743&r2=156744
==============================================================================
--- 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 21:58:34 2005
@@ -33,7 +33,15 @@
         super(testName);
     }
 
-    //FIXME: setup a test to verify that X benchmarks don't use more than Y
+    public void testBenchmarkWithCaller() {
+
+        Benchmark b = Benchmark.getBenchmark( this, "foo" );
+
+        assertEquals( "org.apache.commons.benchmark.Test1#foo", b.getName() );
+        
+    }
+
+    //setup a test to verify that X benchmarks don't use more than Y
     //bytes of memory.
 
     public void testMemory() throws Exception {



---------------------------------------------------------------------
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