How much overhead does a msg_send call incur?

Posted by pxl on Stack Overflow See other posts from Stack Overflow or by pxl
Published on 2010-06-02T23:55:30Z Indexed on 2010/06/03 0:14 UTC
Read the original article Hit count: 633

Filed under:
|
|

I'm attempting to piece together and run a list of tasks put together by a user. These task lists can be hundreds or thousand of items long.

From what I know, the easiest and most obvious way would be to build an array and then iterate through them:

NSArray *arrayOfTasks = .... init and fill with thousands of tasks

for (id *eachTask in arrayOfTasks)
{
  if ( eachTask && [eachTask respondsToSelector:@selector(execute)] ) [eachTask execute];
}

For a desktop, this may be no problem, but for an iphone or ipad, this may be a problem. Is this a good way to go about it, or is there a faster way to accomplish the same thing?

The reason why I'm asking about how much overhead a msg_send occurs is that I could also do a straight C implementation as well. For example, I could put together a linked list and use a block to handle the next task. Will I gain anything from that or is it really more trouble than its worth?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocoa