Hello,
The best way to measure the difference between in-JVM and remote execution would probably be to benchmark them.
You could write code like this to do it:
import java.util.List;
import org.jppf.client.*;
import org.jppf.server.protocol.JPPFTask;
public class Benchmark {
private static JPPFClient client;
public static void main(String...args) {
try {
client = new JPPFClient();
int iterations = 10;
double avgMillis = (executeLocally(iterations) / 1e6) / iterations;
System.out.println("Average local execution time in millis: " + avgMillis);
avgMillis = (executeRemotely(iterations) / 1e6) / iterations;
System.out.println("Average remote execution time in millis: " + avgMillis);
}
catch(Exception e) {
e.printStackTrace();
}
finally {
if (client != null) client.close();
}
}
public static long executeLocally(int iterations) throws Exception {
long start = System.nanoTime();
for (int i=0; i<iterations; i++) createTask().run();
// total elapsed time in nanoseconds
return System.nanoTime() - start;
}
public static long executeRemotely(int iterations) throws Exception {
long start = System.nanoTime();
for (int i=0; i<iterations; i++) {
JPPFJob job = new JPPFJob();
job.addTask(createTask());
List<JPPFTask> results = client.submit(job);
}
// total elapsed time in nanoseconds
return System.nanoTime() - start;
}
public static JPPFTask createTask() {
// create a JPPF task
JPPFTask task = ...;
return task;
}
}
I hope this helps,
-Laurent