You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by gl...@apache.org on 2003/12/10 17:20:02 UTC

cvs commit: jakarta-commons-sandbox/tbm/src/bench/org/apache/commons/tbm/bench BenchTest.java

glenn       2003/12/10 08:20:02

  Modified:    tbm/src/bench/org/apache/commons/tbm/bench BenchTest.java
  Log:
  Move the warmup to a separate Thread object to fix a bug
  with reusing thread[0].
  
  Increase the number of iterations used during warmup to
  allow HotSpot to optimize the code.
  
  Revision  Changes    Path
  1.2       +20 -16    jakarta-commons-sandbox/tbm/src/bench/org/apache/commons/tbm/bench/BenchTest.java
  
  Index: BenchTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/tbm/src/bench/org/apache/commons/tbm/bench/BenchTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BenchTest.java	9 Dec 2003 15:54:11 -0000	1.1
  +++ BenchTest.java	10 Dec 2003 16:20:02 -0000	1.2
  @@ -141,6 +141,22 @@
        * @return boolean Returns false if test could not be run
        */
       public boolean test() {
  +        // Create a test thread to warmp the JVM HotSpot profiler/optimizer
  +        BenchThread warmup = null;
  +        try {
  +            warmup = (BenchThread)testClass.newInstance();
  +            } catch (Exception e) {
  +            error = e.getMessage();
  +            return false;
  +        }
  +        warmup.setIterations(iterations);
  +        warmup.start();
  +        try {
  +            warmup.join();
  +        } catch (InterruptedException e) {
  +        }
  +        warmup.clean();
  +
           // Instantiate as many test thread objects as needed
           for (int i=0; i < threads; i++) {
               BenchThread test = null;
  @@ -153,18 +169,6 @@
               test.setIterations(iterations);
               testObj.add(test);
           }
  -
  -        // Use one test thread to warmup JVM HotSpot profiler/optimizer
  -        // to minimize impact of it on tests.
  -        BenchThread warmup = (BenchThread)testObj.get(0);
  -        warmup.setIterations(10000);
  -        warmup.start();
  -        try {
  -            warmup.join();
  -        } catch (InterruptedException e) {
  -        }
  -        warmup.clean();
  -        warmup.setIterations(iterations);
   
           // Initialize test data
           Runtime rt = Runtime.getRuntime();
  
  
  

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