Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FSDirectorySize code finished



Scott Ribe wrote:

You're obviously not aware of the efficiency of the STL, which is what I was

hinting at in my last post. There's rarely any possibility of being more
efficient than appropriate STL containers properly used--that's one of the
major points of the STL.


I use and love the STL.

That being said, GCC's implementations of set and map are pretty slow. It's O(n) times are always within the limits dictated by the standard, but it is very naive about allocating memory (one malloc per object in the set!) and this adds up fast. OS X's allocator is fast, sure, but it's always faster to avoid the allocation altogether. In some cases, after seeing poor Shark profiles, I've switched existing code from using set<foo> and find to vector<foo> using sort and lower_bound, and seen incredible performance increases. (Obviously, a set much more flexible than a vector in the general case, but if you are just setting up the data once and then using "find" repeatedly, this can work.) If they were to do some sort of pooled allocation, I think it would be make set a lot more competitive.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: FSDirectorySize code finished (From: Scott Ribe <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.