Member 14818745 wrote:
it's giving different execution time on each run
You will not find a deterministic relation between a given function and its execution time, as the latter strongly depends on which other processes are running in the machine at the time the function is executed.
System.nanoTime
is already the most precise form of timer you can get, but precise does not mean constant, it simply means that it has the best time resolution you can get to measure any activity. You can take several measurements and compute their average, if you are not happy with the value returned by a single of them.