I have following code inside a loop:
ekp = e[k][p];
hkp = h[k][p];
uk = round(ekp);
u[k] = uk;
yk = (ekp - uk) / hkp;
y[p] = yk;
The variables are declared the following way:
float ekp, yk, hkp;
int uk;
float **e, *y, **h;
int *u;
I use local variables to store the values from arrays to access them less times. When I profile the code with Xcode I get 9.3% of total execution time on
y[p] = yk;
and only 2.7% on
u[k] = uk;
Why is there such a great difference between storing an int to an array and storing a float?
Would using declaring the variables the following way be more efficient?
register float ekp, yk, hkp;
register int uk;