nLoops = 10000;
nThreads = 1;
doTest(new AtomicRunnable());
doTest(new SyncRunnable());
nLoops = Integer.parseInt(args[0]);
nThreads = Integer.parseInt(args[1]);
System.out.println("Starting atomic test");
cleanGC();
Timestamp atomicTS = new Timestamp();
doTest(new AtomicRunnable());
atomicTS.stop();
System.out.println("Atomic took " + atomicTS);
System.out.println("Starting sync test");
cleanGC();
Timestamp syncTS = new Timestamp();
doTest(new SyncRunnable());
syncTS.stop();
System.out.println("Local sync took " + syncTS);
double d = ((double) (syncTS.elapsedTime() - atomicTS.elapsedTime())) /
(nLoops * nThreads);
System.out.println("Atomic operation saves " + d + " " + syncTS.units() + " per call");