We can measure the time taken by a function in Java with the help of java.lang.System.currentTimeMillis() method. This method returns the current time in millisecond. We can call this method at the beginning and at the end of function and by the difference we measure the time taken by the function.
Loop starts Loop ends Counting to 10000000 takes 8ms
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Difference between Compile-time and Run-time Polymorphism in Java
- New Date-Time API in Java 8
- Java | Current date and time
- Run-time Stack mechanism in Java
- LocalDateTime of(date, time) method in Java with Examples
- Java.util.function.LongPredicate interface in Java with Examples
- Java.util.function.DoublePredicate interface in Java with Examples
- Java.util.function.IntPredicate interface in Java with Examples
- Java.util.function.BiPredicate interface in Java with Examples
- Ints max() function | Guava | Java
- Ints contains() function | Guava | Java
- Java SQL Timestamp before() function with examples
- BigDecimal negate() Function in Java
- Function Interface in Java with Examples
- Cryptographic Hash Function in Java
- Java SQL Timestamp after() function with examples
- BigDecimal compareTo() Function in Java
- Ints min() function | Guava | Java
- What does start() function do in multithreading in Java?
- Java ZipEntry getSize() function with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.