When testing an answer to one of my related questions, I wrote this:
public static long timeDouble(int iters) {
long start = System.currentTimeMillis();
for (; iters >=0; iters--) {
double a = 1.2, b = 2.246, c = 4.4924, d = 8.98488, e = 17.969772;
a = Math.sqrt(a);
b = Math.cos(b);
c = Math.sin(c);
d = Math.tan(d);
e = a + b - c * d / (e + 1);
e = Math.pow(e, e);
}
return System.currentTimeMillis() - start;
}
This method's run time was an average of 414ms (using 1000000 iterations). However, something possessed me to add this line:
e = e + d - c * b / (a + 1);
immediately before e = Math.pow(e, e);
With the addition of this line, the time for calculating this method dropped to an average of 206 ms (using the same test conditions).
What is causing this?