long startTime = System.currentTimeMillis();
long unmonitoredTime = 0, monitoredTime = 0;
int[] numReps = { 1000, 10000, 100000, 1000000};
MonitoredNoOpUDF monitoredUdf = new MonitoredNoOpUDF();
MonitoredUDFExecutor exec = new MonitoredUDFExecutor(monitoredUdf);
UnmonitoredNoOpUDF unmonitoredUdf = new UnmonitoredNoOpUDF();
// warm up
System.out.println("Warming up.");
for (int i : numReps) {
for (int j=0; j < i; j++) {
exec.monitorExec(null);
unmonitoredUdf.exec(null);
}
}
System.out.println("Warmed up. Timing.");
// tests!
for (int k = 0; k < 5; k++) {
for (int i : numReps) {
startTime = System.currentTimeMillis();
for (int j = 0; j < i; j++) {
exec.monitorExec(null);
}
monitoredTime = System.currentTimeMillis() - startTime;
startTime = System.currentTimeMillis();
for (int j = 0; j < i; j++) {
unmonitoredUdf.exec(null);