Is there a way to precisely measure execution time of an algorithm written in Java? My task is to design an algorithm solving TSP, with recommend language used being C++. However, if I want to write it in Java, I have to prove that the measured time is in fact algorithm execution time, and not time taken by any operations JVM might perform whilst running the algorithm.
Using System.nanoTime() right before and after executing the algorithm should be enough, or can I do something more?