C
chinu
hi all,
i did a small experiment to check the effect of inline as a function.
program is like this.
inline int fun();
int main(){
unsigned int start=0,end=0;
asm("rdtsc\t\n""mov %%eax, %0":"=r"(start));
fun();
asm("rdtsc\t\n""mov %%eax, %0":"=r"(end));
printf("No of ticks taken for execution is %d",end-start);
}
inline int fun(){
int x=0;
for(;x<100;x++);
}
i ran same program after removing inline also.. both time, execution
clicks are same, not shwoing any advantages of inline..Does compiler
automatically treat a function inline if function is small..
thanks in advance.
chinmay
i did a small experiment to check the effect of inline as a function.
program is like this.
inline int fun();
int main(){
unsigned int start=0,end=0;
asm("rdtsc\t\n""mov %%eax, %0":"=r"(start));
fun();
asm("rdtsc\t\n""mov %%eax, %0":"=r"(end));
printf("No of ticks taken for execution is %d",end-start);
}
inline int fun(){
int x=0;
for(;x<100;x++);
}
i ran same program after removing inline also.. both time, execution
clicks are same, not shwoing any advantages of inline..Does compiler
automatically treat a function inline if function is small..
thanks in advance.
chinmay