System.out.println(PerformanceSUITE.ITERATION_COUNT + " Invocations, Repeat: x" + PerformanceSUITE.REPEAT_COUNT);
System.out.println("(this may take a while...)\n");
MBeanServer server = MBeanServerFactory.createMBeanServer();
ObjectName name = new ObjectName("Domain:performanceTest=dynamic");
Dyn mbean = new Dyn();
String method = "counter";
long start = 0, end = 0;
float avg = 0l;
server.registerMBean(mbean, name);
// drop the first batch (+1)
for (int testIterations = 0; testIterations < PerformanceSUITE.REPEAT_COUNT + 1; ++testIterations)
{
start = System.currentTimeMillis();
for (int invocationIterations = 0; invocationIterations < PerformanceSUITE.ITERATION_COUNT; ++invocationIterations)
{
server.invoke(name, method, null, null);
}
end = System.currentTimeMillis();
if (testIterations != 0)
{
long time = end - start;
System.out.print( time + " ");
avg += time;
}
}
System.out.println("\nAverage: " + (avg/PerformanceSUITE.REPEAT_COUNT));
MBeanServerFactory.releaseMBeanServer(server);
assertTrue(mbean.getCount() == (PerformanceSUITE.REPEAT_COUNT + 1)*PerformanceSUITE.ITERATION_COUNT);
}
catch (Throwable t)
{
t.printStackTrace();
fail("Unexpected error: " + t.toString());