#include #include @interface MaClasse : NSObject - (void) appel; @end @implementation MaClasse - (void) appel { } @end static void appel (void) { } static inline void appel_enligne (void) { } #define NB_APPELS 1000000000 #define TEST_APPELS(_nom, _appel) \ { \ int i; \ time_t debut, fin; \ \ debut = time (NULL); \ for (i = 0; i < NB_APPELS; i++) \ (_appel); \ fin = time (NULL); \ printf ("Temps execution %s : %fs\n", (_nom), difftime (fin, debut)); \ } int main (int argc, char **argv) { TEST_APPELS("C", appel()); TEST_APPELS("C en ligne", appel_enligne()); MaClasse *obj = [[MaClasse alloc] init]; TEST_APPELS("Objective-C", [obj appel]); IMP methode = [obj methodForSelector: @selector(appel)]; TEST_APPELS("Objective-C en cache", methode(obj, @selector(appel))); }