I have written a custom C code with main and another function being called by main. I am executing this function many times (~1 million). In one code I have declared this function as __inline and in another I have declared it as __declspec(noinline). I monitored the disassemblies using WinDBG and found the latter one is using push pop and branch like a normal function call and the former using no such instructions and properly inlining the function. yet the times for both of them are exactly the same. Following is the code : (Executing this code on A9 cortex CPU (Tegra 3) )
__inline int multifunc(int a, int b);
int main(int argc, char **argv) {
unsigned long int timeBefore, i;
unsigned long int timeAfter;
unsigned int a[11500], j, k, l;
double elapsed;
timeBefore = GetTickCount();
printf("\n%ld", timeBefore);
for(l=1; l<300;l++)
{
for(i=0; i<11500; i++)
{
j = i+l;
k=1;
a[i] = multifunc(j, k);
}
}
printf("\n%ld", timeBefore);
timeAfter = GetTickCount();
printf("\n%ld", timeAfter);
return -1;
}
__inline int multifunc(int a, int b)
{
int d;
d = a+b;
printf("%d", d);
return d;
}
Can anyone explain me why ? All i change for second test is the __inline to __declspec(noinline).