com.jamonapi.TestClassPerformance Maven / Gradle / Ivy
package com.jamonapi;
/**
* Class used to test performance of JAMon. It is only used for testing purposes.
*
* java -cp jamon-2.76.jar com.jamonapi.TestClassPerformance 1000000
*
* @author steve souza
*/
public class TestClassPerformance {
/** Creates a new instance of TestClassPerformance */
public TestClassPerformance() {
this(100000);
}
private int testIterations;
public TestClassPerformance(int testIterations) {
this.testIterations=testIterations;
}
private Monitor testMon;
public void timingNoMonitor() throws Exception {
// The null monitor has the best possible performance
System.out.println("\ntimingNoMonitor() - timing the old fashioned way with System.currentTimeMillis() (i.e.no monitors)");
System.out.println("System.currentTimeMillis() - startTime");
long startTime=0;
// note the assignment to startTime is meaningless. The calculation for elapsed time would really be
// as follows, however being as most implementations of this timing method would not assign the results
// to an endTime variable, I thought it would be a better comparison to also leave it out in the performance
// test.
// startTime = System.currentTimeMillis();
// endTime = System.currentTimeMillis() - startTime;
for (int i=0; i