Re: Speed comparison: compare:, methodForSelector: & CFNumberCompare()
Re: Speed comparison: compare:, methodForSelector: & CFNumberCompare()
- Subject: Re: Speed comparison: compare:, methodForSelector: & CFNumberCompare()
- From: "Louis C. Sacha" <email@hidden>
- Date: Sun, 22 Feb 2004 13:46:58 -0800
Hello...
Part of the issue might be that there are regular objective-C
messages happening within the compare: implementation. So using an
IMP only shaves off the overhead for the intial message, and you
still have the difference between the internal messages in compare:
and plain C functions in CFNumberCompare(), multiplied by 100,000.
I would guess that the NSNumber implementation of compare: does not
call CFNumberCompare(), and probably implements its own version,
using messages to get the pertinent information from each NSNumber
object involved in the comparison. The reason (for my guess) is that
there are some situations in Cocoa that might prevent the use of
CoreFoundation functions because of the objective-C nature of Cocoa
-- one of the objects involved might not actually be an NSNumber, it
could be a proxy to an NSNumber, ect... I don't think there is any
guarantee that Core Foundation and/or the built in toll-free bridging
would be able to handle that situation, but it works transparently
when messages are used.
Louis
On 22. Feb 2004, at 20:48, Public Look wrote:
Here is an interesting observation. Sorting 100,000 random
integers in different ways (with std::sort): [...]
See http://www.mulle-kybernetik.com/artikel/Optimization/opti.html
Should there be anything specific on that page which explains the
difference between calling the CF function and using the Cocoa
implementation function pointer?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.