The com.develop.benchmark package has been moved to DM.jar project, you can download it there.
The package provides code to do quick-and-dirty benchmarking of small pieces of Java code. All of the heavy lifting is done in the Timer class, which uses a background thread to start and stop the test. To add your own tests to the framework, simply extend the Timer class, and paste a copy of the test method into your subclass:
protected void test(int iter) {
int a,b,c; //kill implicits
long n=0;
startTest(iter);
for (n=0; go; n++) {
}
endTest(n, iter);
}
Just add the code you want to test inside the for loop, and then pass your class to Timer on the command line:
java com.develop.benchmark.Timer YourSubclass1 YourSubclass2 Etc
For an interesting example of using the Timer, execute the TimeMethodInvoke.cmd script to time various styles of method invocation in Java.
The Timer does not deal with garbage collection. It does run each test multiple times, so if one result is way out of whack you should suspect GC or some other activity on your system.
Some of the sample test code requires JDK 1.3. You can remove these files from the build and safely build the core testing harness under 1.2.
The CPP subdirectory contains a C++ version of the benchmarking code. (I wrote this to prove to myself that I still knew C++.) The C++ code is clunkier than the Java code, and requires a recompile of the Timer.cpp file when you add a test.
This code is inspired by Doug Bell's Java Optimization Article. Doug's code has more features--I wrote the benchmark package as a minimal version of the same idea, so that students could follow the code more easily.
The com.develop.benchmark package is open source, subject to the following license.