public class Main { public static void main(String[] args) { long start = System.nanoTime(); // block of code to time long end = System.nanoTime(); System.out.println("It took " + (end - start) + " nanoseconds"); } }