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
- BigDecimal negate() Function in Java
- Function Interface in Java with Examples
- Ints max() function | Guava | Java
- Ints contains() function | Guava | Java
- BigDecimal compareTo() Function in Java
- Ints min() function | Guava | Java
- What does start() function do in multithreading in Java?
- Sets powerSet() function | Guava | Java
- Sets union() function | Guava | Java
- BigIntegerMath divide() function | Guava | Java
- Java Function/Constructor Overloading Puzzle
- Ints concat() function | Guava | 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.