I need to compare the run time of 2 programs. I capture the elapsed time of each program using System.nanoTime()
. One program returns with a time of 1449870040074994000 nano seconds, the other with a time of 1449870040080970000 nano seconds.
I am using double percent = ((big-small)/big)*100;
but this is returning 0.0. Is this because double can't represent such a small number?
What am I doing wrong and how can I calculate this correctly?
Note that I need to make a conclusion along the lines of "Program A is on average x% faster than Program B"
Thanks!