import java.time.Duration; import java.time.Instant; public class RunningTime { public static void main(String[] args) { //start time Instant start = Instant.now(); for(int idx = 1; idx <= 100000; idx++) { //System.out.println(idx); } // end time Instant end = Instant.now(); // running time of code System.out.println("Running time in ms: " + Duration.between(start, end)); } }