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
- New Date-Time API in Java 8
- Run-time Stack mechanism in Java
- Java | Current date and time
- Java.util.function.DoublePredicate interface in Java with Examples
- Java.util.function.BiPredicate interface in Java with Examples
- Java.util.function.IntPredicate interface in Java with Examples
- Java.util.function.LongPredicate interface in Java with Examples
- Ints max() function | Guava | Java
- Function Interface in Java with Examples
- Ints min() function | Guava | Java
- Java SQL Timestamp before() function with examples
- Java SQL Timestamp after() function with examples
- BigDecimal compareTo() Function in Java
- Ints contains() function | Guava | Java
- What does start() function do in multithreading in Java?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.