Function Call Benchmarks for Objective-C

Lets run some benchmarks on the different ways to call functions.  Today’s contestants are C Functions, C Function Pointers, C Blocks, C++ Virtual Methods, and Objective-C Methods.

The Code:

The System:

Mac OS X 10.9.3 : LLVM 3.4

Generated Assembly:

c function:

c function pointer:

c block:

c++ virtual method:

objc method:


The Results:

c function – useconds/call:0.004192
c function pointer – useconds/call:0.004705
c block – useconds/call:0.004320
c++ virtual method – useconds/call:0.004731
objc method – useconds/call:0.006549


Objective-C is slow because it is performing more code inside of objc_msgSend but the others are roughly performing the same number of operations.  The only differences are the number of reads from memory they have.

Leave a Reply

Your email address will not be published. Required fields are marked *