How to measure time taken by Java code?

java, time-complexity

Solution

You can get nanosecond resolution, even, using `System.nanoTime()`.

However, you may want to consider the points in the following:

How do I write a correct micro-benchmark in Java?

Problem

I need to analyze complexity for some algorithms in Java. For that I am planning to give large number of input and measure the time taken by Java implementation. What is the most precise and accurate way to check time between some lines of code? I need precision in milliseconds...

Original source

Related problems