optimisation with method use count
Let suppose we have the following method :
public void doABigLoop()
{
double d = 0;
// do a loop 1000000000 times
{
double d2 = Math.sin(d) * d + Math.cos(d);
System.out.println("d2="+d2);
}
}
Now, if we replace this code with the following :
public void doABigLoop()
{
double d = 0;
// do a loop 1000000000 times
{
doSomething(d);
}
}
public void doSomething(double d)
{
double d2 = Math.sin(d) * d + Math.cos(d);
System.out.println("d2="+d2);
}
Then, as doSomething is called 1000000000 times, this method should be full optimized by out optimizer. In theory, the second code should be faster than the first.
If verified in reality with JNode, we can deduce some optimization technics (we must take into account the time needed by the optimizer to do his job).
- Login to post comments