threadr.addTasks(test);
for (ThreadrTest t : test) {
Threadr.logger.finer(t.toString());
}
startTime = System.currentTimeMillis();
ThreadrResult results = threadr.execute();
endTime = System.currentTimeMillis();
diff2 = endTime - startTime;
pars.add(diff2);
double totalMem = threadr.getMemoryMonitor().getMaxUsedMemory(MemoryUnits.MEGABYTE);
/* Get all the MemoryMonitors out from the results. */
for (AbstractReturnType<?> result : results.getResults()) {
/*
* If the monitors are different, we must be looking at
* another VM.
*/
MemoryMonitor resultMon = (MemoryMonitor) result.getResult();
if (!result.getResult().equals(threadr.getMemoryMonitor())) {
totalMem += resultMon.getMaxUsedMemory(MemoryUnits.MEGABYTE);
}
}
parMemUse.add(totalMem);
Threadr.logger
.fine(String
.format("\nVirtual Machine tasks execution time %dms\n",
diff2));
for (AbstractReturnType<?> result : results.getResults()) {
Threadr.logger.finer(result.toString());
}
/* Work out the percentage increase in execution speed. */
float percentage = (((float) (diff1 - diff2) / (float) diff1) * 100.0f);
impsPar.add(percentage);
Threadr.logger.fine(String.format(
"\tImprovement: %03.02f%% \n", percentage));
/* Set up and test threaded executions. */
System.gc();
threadr.reset();
threadr.addTasks(test2);
for (Test2 t : test2) {
Threadr.logger.finer(t.toString());
}
startTime = System.currentTimeMillis();
results = threadr.execute();
endTime = System.currentTimeMillis();
diff3 = endTime - startTime;
thrs.add(diff3);
totalMem = threadr.getMemoryMonitor().getMaxUsedMemory(MemoryUnits.MEGABYTE);
for (AbstractReturnType<?> result : results.getResults()) {
MemoryMonitor resultMon = (MemoryMonitor) result
.getResult();
if (!result.getResult().equals(threadr.getMemoryMonitor())) {
totalMem += resultMon.getMaxUsedMemory(MemoryUnits.MEGABYTE);
}
}
thrMemUse.add(totalMem);
Threadr.logger.fine(String.format(
"\tThreaded tasks execution time %dms\n", diff2));
for (AbstractReturnType<?> result : results.getResults()) {
Threadr.logger.finer(result.toString());
}
/* Work out the percentage increase in execution speed. */
percentage = (((float) (diff1 - diff3) / (float) diff1) * 100.0f);
impsThr.add(percentage);