C
chinu
hi all,
i did a small experiment to grasp the advantages of declaring a
function as inline.
inline int fun1();
int main(){
unsigned int start=0,end=0;
asm("rdtsc\n\t"
"mov %%eax, %0\n\t":"=m"(start);
// cout<<"Start value is "<<start<<endl;
fun1();
asm("rdtsc\n\t"
"mov %%eax, %0\n\t":"=m"(end);
cout<<"time taken is "<<end-start<<endl;
}
inline int fun1(){
int a=1990;
a++;
for(a=0;a<1000;a++);
/* just to consume some time*/
}
i ran above program with inline declaration of fun1 and without inline
declaration of fun1, both times, total time taken was same...
am i doing something wrong?
regards
chinmay
-----------------------------------------------blissful
ignorance--------------------------------------------------------------
~
i did a small experiment to grasp the advantages of declaring a
function as inline.
inline int fun1();
int main(){
unsigned int start=0,end=0;
asm("rdtsc\n\t"
"mov %%eax, %0\n\t":"=m"(start);
// cout<<"Start value is "<<start<<endl;
fun1();
asm("rdtsc\n\t"
"mov %%eax, %0\n\t":"=m"(end);
cout<<"time taken is "<<end-start<<endl;
}
inline int fun1(){
int a=1990;
a++;
for(a=0;a<1000;a++);
/* just to consume some time*/
}
i ran above program with inline declaration of fun1 and without inline
declaration of fun1, both times, total time taken was same...
am i doing something wrong?
regards
chinmay
-----------------------------------------------blissful
ignorance--------------------------------------------------------------
~