When i try to measure the performance execution speed time of my method below:
public static int FFMulFast(int firstPol, int secondPol){
int temp = 0;
if (firstPol == 0 ||secondPol == 0)
return 0;
/*The multiplication is done by using lookup tables. We have used both logarithmic and exponential table for mul
the idea is firstly look to Logarithmic table then add their powers and find the corresponding of this to exponential table */
temp = (Log[(firstPol & 0xff)] & 0xff) + (Log[(secondPol & 0xff)] & 0xff);
if (temp > 255) temp = temp - 255;
return Exp[(temp & 0xff)];
}
Now when i measure the performance speed of this method as below
public void runABunch() {
long start = System.nanoTime();
int a=0x59;
int b=0xb4;
for (int i = 0; i < 5000000; i++)
FFMulFast(a,b);
long end = System.nanoTime();
System.out.println("Time in nanoseconda: " + (end-start));
}
The result of this one is approximately 0.1 seconds .
But when i run the same method runABunch but omitted for then i get totally different results and i do not understand why these results are totally different and which one is more reputable the one with for or the one without for
public void runABunch() {
long start = System.nanoTime();
int a=0x59;
int b=0xb4;
FFMulFast(a,b);
long end = System.nanoTime();
System.out.println("Time in nanoseconda: " + (end-start));
}
Also when i put some println statements the time of execution increased a lot.Anyone know why? I tried to use profiler like java visualvm but the problem is that i can not see anything there since it disappeared to me as soon as my application finished to run.