long startTime = System.nanoTime(); myMethod(); long stopTime = System.nanoTime(); System.out.println(stopTime - startTime);