long startTime = System.nanoTime(); .....your program.... long endTime = System.nanoTime(); long totalTime = endTime - startTime; System.out.println(totalTime);