Re: Speed Traps
Re: Speed Traps
- Subject: Re: Speed Traps
- From: Nat! <email@hidden>
- Date: Thu, 15 May 2003 00:56:38 +0200
Am Donnerstag, 15.05.03 um 00:07 Uhr schrieb John Nairn:
I spent a day rewriting a custom expression parcer for what I hoped
would give me much more speed but the final result is now slower. It
is hard to believe it is slower; could I be missing some Cocoa speed
traps?
First version parced a NSString expression and evaluated as it went.
New version tokenizes the expression on the first past and then all
subsequent passes do no parcing, but just evaluate using the tokens.
The new version evaluation with tokens is slower than the first
version that parced AND evaluated on every pass. It does not make
sense and I am hoping I missed something or am using some Cocoa
feature in new version that is cause speed hang up?
One finding and maybe clue to speed traps:
In evaluating from tokens for expressions with groupings, I recursive
pass sub arrays of tokens to a function. If I allocate the sub arrays
and release them it it is slower than using autoreleased arrays. In
other words
subExpr=[[NSMutableArray alloc] initWithArray:...]
evaluate
[subExpr release];
is noticeably slower than
subExpr=[NSMutableArray arrayWithArray:...]
evaluate
Well commenting on just those code snippets: with [supExpr release] you
are really deleting the array and releasing all of its contents,
whereas with the factory method you are postponing this to a time,
where you might not be measuring anymore.
If that is true, than the factory method is even a smart optimization.
Anyway, run Sampler.app on your program and check out where the cycles
are lost :)
Ciao
Nat!
-----------------------------------------------------
But didn't I always tell you, honey, if I just stayed
in place and I never spoke up, good things are bound
to happen ? -- Jonathan Gems
_______________________________________________
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.
References: | |
| >Speed Traps (From: John Nairn <email@hidden>) |