Stopwatch stopwatch =newStopwatch().start(); //do something test for(int i =0; i <10000; i++){ } long nanos = stopwatch.elapsed(TimeUnit.NANOSECONDS); System.out.println(nanos);