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
- BigDecimal negate() Function in Java
- Ints min() function | Guava | Java
- BigDecimal compareTo() Function in Java
- What does start() function do in multithreading in Java?
- Function Interface in Java with Examples
- Java SQL Timestamp before() function with examples
- Ints max() function | Guava | Java
- Java SQL Timestamp after() function with examples
- Ints contains() function | Guava | Java
- Java ZipEntry setComment() function with examples
- File setReadable() function in Java with Examples
- Java ZipEntry setCompressedSize() 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.