Re: Cocoa et al as HCI usability problem
Re: Cocoa et al as HCI usability problem
- Subject: Re: Cocoa et al as HCI usability problem
- From: Bill Bumgarner <email@hidden>
- Date: Fri, 23 May 2008 22:08:58 -0700
On May 23, 2008, at 9:19 PM, Graham Cox wrote:
On 24 May 2008, at 7:34 am, Bill Bumgarner wrote:
The NSEnumerator stuff is prone to introducing silly errors, is
inefficient, and not very pleasant to look at.
Can you go into more detail about the efficiency improvements? I do
use a lot of NSEnumeration-based code and this *could* convince me
to use Obj-C 2.0 enumeration (though at present I'm still rather
keen to support Tiger). What sort of gains are we looking at? twice
as fast? ten times? Or 1.1 times?
Sure. It largely depends on the # of objects in the collection, the
type of collection, and how effectively it adopts fast enumeration
internally. For example, a simple, unscientific, test of the speed
of fast enumeration vs. NSEnumerator (code below) shows improvements
anywhere from 1.02x to 6.5x when using fast enumeration on the
Foundation collection classes.
NSMutableArray 1000000 elements: NSEnum: 0.02609900, Fast:
0.00978100, 2.67x faster.
NSMutableDictionary 1000000 elements: NSEnum: 0.37828702, Fast:
0.09805402, 3.86x faster.
NSMutableSet 1000000 elements: NSEnum: 0.16853702, Fast:
0.09868801, 1.71x faster.
NSMutableArray 100000 elements: NSEnum: 0.00392699, Fast:
0.00120100, 3.27x faster.
NSMutableDictionary 100000 elements: NSEnum: 0.02237800, Fast:
0.00658801, 3.40x faster.
NSMutableSet 100000 elements: NSEnum: 0.00787699, Fast:
0.00525400, 1.50x faster.
NSMutableArray 10000 elements: NSEnum: 0.00037798, Fast:
0.00009000, 4.20x faster.
NSMutableDictionary 10000 elements: NSEnum: 0.00206998, Fast:
0.00031900, 6.49x faster.
NSMutableSet 10000 elements: NSEnum: 0.00066799, Fast:
0.00031501, 2.12x faster.
NSMutableArray 1000 elements: NSEnum: 0.00003898, Fast:
0.00000900, 4.33x faster.
NSMutableDictionary 1000 elements: NSEnum: 0.00020900, Fast:
0.00003800, 5.50x faster.
NSMutableSet 1000 elements: NSEnum: 0.00007099, Fast:
0.00003600, 1.97x faster.
NSMutableArray 100 elements: NSEnum: 0.00000498, Fast:
0.00000101, 4.91x faster.
NSMutableDictionary 100 elements: NSEnum: 0.00002298, Fast:
0.00000402, 5.71x faster.
NSMutableSet 100 elements: NSEnum: 0.00000900, Fast:
0.00000498, 1.81x faster.
NSMutableArray 10 elements: NSEnum: 0.00000101, Fast:
0.00000000, infx faster.
NSMutableDictionary 10 elements: NSEnum: 0.00000301, Fast:
0.00000098, 3.06x faster.
NSMutableSet 10 elements: NSEnum: 0.00000200, Fast:
0.00000101, 1.97x faster.
NSMutableArray 1 elements: NSEnum: 0.00000101, Fast:
0.00000000, infx faster.
NSMutableDictionary 1 elements: NSEnum: 0.00000098, Fast:
0.00000101, 0.97x faster.
NSMutableSet 1 elements: NSEnum: 0.00000200, Fast:
0.00000000, infx faster.
[albbum:/tmp] bbum% /tmp/bbum-products/Release/arrayness
NSMutableArray 1000000 elements: NSEnum: 0.02728599, Fast:
0.00976601, 2.79x faster.
NSMutableDictionary 1000000 elements: NSEnum: 0.36168000, Fast:
0.09585199, 3.77x faster.
NSMutableSet 1000000 elements: NSEnum: 0.16494402, Fast:
0.10098702, 1.63x faster.
NSMutableArray 100000 elements: NSEnum: 0.00387901, Fast:
0.00090900, 4.27x faster.
NSMutableDictionary 100000 elements: NSEnum: 0.02162600, Fast:
0.00659698, 3.28x faster.
NSMutableSet 100000 elements: NSEnum: 0.00786901, Fast:
0.00474098, 1.66x faster.
NSMutableArray 10000 elements: NSEnum: 0.00037602, Fast:
0.00009099, 4.13x faster.
NSMutableDictionary 10000 elements: NSEnum: 0.00224701, Fast:
0.00044498, 5.05x faster.
NSMutableSet 10000 elements: NSEnum: 0.00067902, Fast:
0.00031900, 2.13x faster.
NSMutableArray 1000 elements: NSEnum: 0.00003999, Fast:
0.00000900, 4.44x faster.
NSMutableDictionary 1000 elements: NSEnum: 0.00021100, Fast:
0.00003701, 5.70x faster.
NSMutableSet 1000 elements: NSEnum: 0.00007400, Fast:
0.00003600, 2.06x faster.
NSMutableArray 100 elements: NSEnum: 0.00000501, Fast:
0.00000101, 4.94x faster.
NSMutableDictionary 100 elements: NSEnum: 0.00002202, Fast:
0.00000399, 5.51x faster.
NSMutableSet 100 elements: NSEnum: 0.00000900, Fast:
0.00000399, 2.25x faster.
NSMutableArray 10 elements: NSEnum: 0.00000101, Fast:
0.00000000, infx faster.
NSMutableDictionary 10 elements: NSEnum: 0.00000301, Fast:
0.00000101, 2.97x faster.
NSMutableSet 10 elements: NSEnum: 0.00000301, Fast:
0.00000101, 2.97x faster.
NSMutableArray 1 elements: NSEnum: 0.00000101, Fast:
0.00000000, infx faster.
NSMutableDictionary 1 elements: NSEnum: 0.00000200, Fast:
0.00000000, infx faster.
NSMutableSet 1 elements: NSEnum: 0.00000098, Fast:
0.00000101, 0.97x faster.
[albbum:/tmp] bbum% /tmp/bbum-products/Release/arrayness
NSMutableArray 1000000 elements: NSEnum: 0.02743700, Fast:
0.01021200, 2.69x faster.
NSMutableDictionary 1000000 elements: NSEnum: 0.35862097, Fast:
0.09460899, 3.79x faster.
NSMutableSet 1000000 elements: NSEnum: 0.16318601, Fast:
0.09644902, 1.69x faster.
NSMutableArray 100000 elements: NSEnum: 0.00378001, Fast:
0.00091898, 4.11x faster.
NSMutableDictionary 100000 elements: NSEnum: 0.02161402, Fast:
0.00692201, 3.12x faster.
NSMutableSet 100000 elements: NSEnum: 0.00791001, Fast:
0.00461099, 1.72x faster.
NSMutableArray 10000 elements: NSEnum: 0.00049099, Fast:
0.00008699, 5.64x faster.
NSMutableDictionary 10000 elements: NSEnum: 0.00208598, Fast:
0.00033700, 6.19x faster.
NSMutableSet 10000 elements: NSEnum: 0.00067300, Fast:
0.00031400, 2.14x faster.
NSMutableArray 1000 elements: NSEnum: 0.00003901, Fast:
0.00000900, 4.33x faster.
NSMutableDictionary 1000 elements: NSEnum: 0.00022802, Fast:
0.00003698, 6.17x faster.
NSMutableSet 1000 elements: NSEnum: 0.00007200, Fast:
0.00003701, 1.95x faster.
NSMutableArray 100 elements: NSEnum: 0.00000498, Fast:
0.00000101, 4.91x faster.
NSMutableDictionary 100 elements: NSEnum: 0.00002301, Fast:
0.00000399, 5.76x faster.
NSMutableSet 100 elements: NSEnum: 0.00000900, Fast:
0.00000399, 2.25x faster.
NSMutableArray 10 elements: NSEnum: 0.00000101, Fast:
0.00000098, 1.03x faster.
NSMutableDictionary 10 elements: NSEnum: 0.00000301, Fast:
0.00000101, 2.97x faster.
NSMutableSet 10 elements: NSEnum: 0.00000200, Fast:
0.00000101, 1.97x faster.
NSMutableArray 1 elements: NSEnum: 0.00000098, Fast:
0.00000000, infx faster.
NSMutableDictionary 1 elements: NSEnum: 0.00000101, Fast:
0.00000098, 1.03x faster.
NSMutableSet 1 elements: NSEnum: 0.00000200, Fast:
0.00000000, infx faster.
(Yah -- the numbers get a bit dodgy for very small collection sizes...
"infinitely faster" isn't really true. :)
Also, if I use a method such as [array
makeObjectPerformSelector:...] does that use fast enumeration
internally?
It should be using something as fast or faster.
b.bum
Attachment:
arrayness.m
Description: Binary data
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden