int warmuptime = performanceAnnotation.warmuptime();
int runtime = performanceAnnotation.runtime();
int warmupinvocations = performanceAnnotation.warmupinvocations();
int runinvocations = performanceAnnotation.runinvocations();
DescriptiveStatistics statistics = new DescriptiveStatistics();
if (warmupinvocations != 0) {
// Run the number of invocation specified in the annotation
// for warming up the system
for (int invocationIndex = 0; invocationIndex < warmupinvocations; invocationIndex++) {
recursiveCallSpecificMethod(this.target.getClass(), this.target, BeforeMethodInvocation.class);
// TODO: implement the method to run a before a specific test
// method
// recursiveCallSpecificMethod(this.target.getClass(),
// this.target, BeforeSpecificTest.class);
response = super.invokeExplosively(this.target, params);
// TODO: implement the method to run a after a specific test
// method
// recursiveCallSpecificMethod(this.target.getClass(),
// this.target, AfterSpecificTest.class);
recursiveCallSpecificMethod(this.target.getClass(),
this.target, AfterMethodInvocation.class);
}
} else {
// Run a few iterations to warm up the system
long warmupEnd = System.currentTimeMillis() + warmuptime * 1000;
while (System.currentTimeMillis() < warmupEnd) {
recursiveCallSpecificMethod(this.target.getClass(),
this.target, BeforeMethodInvocation.class);
// TODO: implement the method to run a before a specific test
// method
// recursiveCallSpecificMethod(this.target.getClass(),
// this.target, BeforeSpecificTest.class);
response = super.invokeExplosively(this.target, params);
// recursiveCallSpecificMethod(this.target.getClass(),
// this.target, AfterSpecificTest.class);
// TODO: implement the method to run a after a specific test
// method
recursiveCallSpecificMethod(this.target.getClass(),
this.target, AfterMethodInvocation.class);
}
}
// System.out.println("Warmup ended - test :" +
// testMethodToInvoke.getName());
if (runinvocations != 0) {
// Run the specified number of iterations and capture the execution
// times
for (int invocationIndex = 0; invocationIndex < runinvocations; invocationIndex++) {
response = this.invokeTimedTestMethod(testMethodToInvoke,
statistics, params);
}
} else {
// Run test iterations and capture the execution times
long runtimeEnd = System.currentTimeMillis() + runtime * 1000;
while (System.currentTimeMillis() < runtimeEnd) {
response = this.invokeTimedTestMethod(testMethodToInvoke,
statistics, params);
}
}
if (statistics.getN() > 0) {
ReportLogger.writeReport(this.performanceSuiteState.testSuiteName, testCaseName, className, getMethod().getName(),
statistics, ReportLogger.ReportType.TXT, reportLevel);
}
// In case of a PerformanceSuite we need to run the methods annotated