Getting/installing/running JBench

Getting JBench

Download JBench from the download page on the JBench web site.

Installing JBench

JBench can be downloaded in three forms - the binary distribution (including documentation), the source distribution, or the plain jar file on its own. If you download the source distribution, you'll need to build JBench before using it. Whichever form you download, however, you'll end up with a JBench.jar file. That's all you'll really need just to use JBench.

Running JBench

The jar file is an "executable jar file" which means it can be run directly on Java2 VMs using a command like this:
java -jar JBench.jar jbench.properties
Alternatively, you can always put JBench.jar in your classpath. Unfortunately, putting JBench in your extension directory won't work, as its classloader then won't be able to find your task classes. With JBench in your classpath, you should use:
java uk.org.skeet.jbench.JBench jbench.properties

The above examples use jbench.properties as the configuration file, but you can, of course, call the configuration file whatever you like - just put it as the parameter.

When you use the first form (ie when you use the -jar option) any classpath options you've set up for your environment are ignored - this is just how executable jar files work. However, I have included "." in the classpath that the jar file uses, so any class files based in the same directory as JBench.jar will be picked up. If you wish to use other entries in your classpath, I suggest you put JBench.jar in your classpath and use the second form.

Checking that JBench works

JBench comes with an example task (ListSort) built into the main jar file. That makes it very easy to check that JBench is working. Simply copy the jbench.properties file into the same directory as JBench.jar, and run it using either of the ways given above. You should get results that look something like this:

--- JBench log Sat Aug 25 14:12:05 BST 2001 ---
System properties:
  VM: Java HotSpot(TM) Client VM;1.3.1-b24;Sun Microsystems Inc.
  OS: Windows 2000;x86;5.0
  Clock granularity: 10ms
General Configuration:
  Number of test runs per task: 5
  Abort on task configuration error: no
  Excluding worst result and best result from stats.
Task configuration:
  Configured Collections.sort(java.util.ArrayList) size=1000000
  Configured Collections.sort(java.util.Vector) size=1000000
2 tasks successfully configured.
Running tests...
-----------
Collections.sort(java.util.ArrayList) size=1000000
  Testing.....
  All tests passed. Results:
       4286ms  [excluded]
       4186ms
       4186ms
       4186ms
       4176ms  [excluded]
Mean=4186; variance=0; standard deviation=0
-----------
Collections.sort(java.util.Vector) size=1000000
  Testing.....
  All tests passed. Results:
       4015ms  [excluded]
       4016ms
       4016ms
       4016ms
       4026ms  [excluded]
Mean=4016; variance=0; standard deviation=0
-----------

(If it looks like it's hung, give it some time and watch the dots after "Testing.."; one dot is printed for each test run - if it's going very slowly, you may wish to decrease the size parameters in jbench.properties.)

If the results don't look anything like that, and you can't work out why, mail me and I'll try to sort it out.

That's it, pretty much - you may wish to experiment with the parameters in jbench.properties a bit, but I expect you'll be more interested in developing your own tasks.


JBench Manual