!752 p { bench(r { shootScreen2(0, 0, 200, 100) }, 100); bench(r { new BWImage(shootScreen2(0, 0, 200, 100)) }, 100); //bench(r { shootScreen2() }, 1); bench(r { new BWImage(shootScreen2()) }, 1); } static int bench_seconds = 5; svoid bench(Runnable runnable, int repetitions) { long start = now(); while (now()-start < bench_seconds*1000) { // do it for at least x seconds long time = now(); for i to repetitions: runnable.run(); double duration = (now()-time)/(double) repetitions; print(runnable + ": " + formatDouble(duration, 1) + " ms"); } }