#include static inline unsigned long long int llclock(void) { unsigned long long int a; asm volatile ("rdtsc" : "=&A" (a)); return a; } void foo(void) __attribute__ ((weak)); void foo(void) { } void foo2(id foo, SEL s) __attribute__ ((weak)); void foo2(id foo, SEL s) { } int i=1000; void (*foo2_id)(id,SEL)=foo2; @implementation Object (foo) -(void) foo { } @end int main(int argc, char **argv) { unsigned long long int t1,t2; id self=[Object alloc]; SEL cmd=@selector(foo); void (*foo3)(id,SEL)=foo2_id; t1=llclock(); while (i--) { // foo(); /* ~6 cycles/call */ // foo2(self,cmd); /* ~8 cycles/call */ // foo3(self,cmd); /* ~9 cycles/call */ [self foo]; /* ~24 cycles/call */ } t2=llclock(); t2-=t1; printf("%llu clock cycles\n",t2); return 0; }