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
- Java | Current date and time
- Run-time Stack mechanism in Java
- Java.util.function.IntPredicate interface in Java with Examples
- Java.util.function.LongPredicate interface in Java with Examples
- Java.util.function.BiPredicate interface in Java with Examples
- Java.util.function.DoublePredicate interface in Java with Examples
- BigDecimal negate() Function in Java
- Ints max() function | Guava | Java
- Ints contains() function | Guava | Java
- Function Interface in Java with Examples
- BigDecimal compareTo() Function in Java
- What does start() function do in multithreading in Java?
- Java SQL Timestamp before() function with examples
- Java SQL Timestamp after() function with examples
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.