ObjC in time-critical parts of the code
ObjC in time-critical parts of the code
- Subject: ObjC in time-critical parts of the code
- From: Jens Bauer <email@hidden>
- Date: Thu, 15 Jan 2009 23:16:02 +0100
Hi all,
I just want to let you know that I discovered I did a terrible mistake
today.
In other words: you don't have to learn from your own mistakes, if you
can learn from mine. =)
I investigated this, because my rendering was choppy.
The code...
- (void)renderObject
{
}
- (void)renderAll
{
UnsignedWide us;
double time;
Microseconds(&us);
time = ((double) us.hi) * 65536.0 * 65536.0 + ((double) us.lo);
[self renderObject];
Microseconds(&us);
time = ((double) us.hi) * 65536.0 * 65536.0 + ((double) us.lo) - time;
NSLog(@"time:%.3fms", time * 0.001);
}
..often used around 3ms for the empty method "-renderObject".
It gave me the terrible result of up to 21ms spent in the empty method!
-So I'd like to let you know that it's sometimes good to think "do I
really need this method?"
I will be rewriting around 8 of my large files for doing some
rendering, so they will be using C-routines instead of ObjC methods,
since I'm using them in a real-time environment.
My guess is that the message dispatcher probably needs to do something
else than servicing *my* application, so I believe it's the nature of
the environment, not a bug.
Love,
Jens
_______________________________________________
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