First slow, then fast
First slow, then fast
- Subject: First slow, then fast
- From: Lorenzo <email@hidden>
- Date: Mon, 04 Aug 2003 00:57:52 +0200
Hi list,
I have a problem at my Cocoa app that I cannot understand.
I turn on the machine, MacOS X 10.2.6, TiG4 1GHz, I log in, I see the
desktop, everything is ready, but just to be sure the machine finished to do
everything, I wait two minutes. I launch my Cocoa application.
in the awakeFromNib I do
- (void)awakeFromNib{
foundArray = [[NSMutableArray arrayWithCapacity:0] retain];
then I launch a search in the boot disk and I add an object (a NSString*) to
the foundArray for each file matching my query. So I get 8,000 objects in
the foundArray then I show this list in a NSTableView. Well.
The first time I launch this search, it takes 15 seconds.
The second time, and all the next times it takes 2 or 3 seconds.
WHY?
I don't think it's because of the cache, because I start a search any time.
I thought it's because the first time my app has to allocate memory each
time it adds an object to the array. Instead at the next searches, the
memory is already allocated so it is faster (even if I removeAllObjects from
the array before executing the search).
So I changed that line of code to
- (void)awakeFromNib{
foundArray = [[NSMutableArray arrayWithCapacity:10000] retain];
but the problem is still there.
So I tried to do this:
- (void)awakeFromNib{
Handle h = NewHandle(20000000);
DisposeHandle(h);
foundArray = [[NSMutableArray arrayWithCapacity:10000] retain];
but the problem is still there.
May anyone help me and make me understand?
Thank you.
Best Regards
--
Lorenzo
email: email@hidden
_______________________________________________
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.