Re: Tracking animation in multiple windows using NSTimer vs NSThread?
Re: Tracking animation in multiple windows using NSTimer vs NSThread?
- Subject: Re: Tracking animation in multiple windows using NSTimer vs NSThread?
- From: "l.m.orchard" <email@hidden>
- Date: Sun, 12 Aug 2001 15:20:44 -0400
On Sunday, August 12, 2001, at 02:03 PM, Chris Kane wrote:
On Saturday, August 11, 2001, at 08:56 PM, l.m.orchard wrote:
Problem is that I use 100% CPU, and I think it's because I'm trying to
make the run loop do too much. [...]
So I'm wondering which part of this process is so heavyweight.
Run Sampler in /Developer/Applications. Point it at your program and run
your program under Sampler for a while. Sampler takes a snapshot of the
threads' call stacks at a periodic interval, and collects the results
into a "tree"/browser. The paths through the tree with the largest
numbers are where Sampler caught the app the most, which are where the
app is spending most of its time.
Hmm... looks like it's spending most of the time handling displayIfNeeded:
One thing I just did which seems to have cut the CPU usage by about 25%
was to drive the TableListView updating with a timer reoccurring every 0.5
sec. So before, the TableListView was almost constantly reloading data
because every window controller messaged to the main controller to update
data every time a ball moved, which was every 0.05 sec. Now, I just
'sample' every 0.5 sec.
But the other thing is my method of animation. I have a custom view, with
a circle drawn by an NSBezierPath, and moved to the current location via
an NSAffineTransform (with translateXBy:yBy:). The circle is set up in
initWithFrame. Every 0.05 sec, the animation timer calls a message which
updates the position of the circle and calls [self setNeedsDisplay:YES];
And when called, drawRect: creates a new NSAffineTransform with the
translation with which I then do [[circleTransform
transformBezierPath:circleBezier] stroke];
This seems to be pretty heavyweight. So I'm thinking that I don't want to
try animating anything like this. Is there a better way? Is this what
NSQuickView is for?
Mostly just curious about the animation, since it's not my main goal for
what I'm working on now...
--
Leslie Michael Orchard <email@hidden>
ICQ: 492905 (home) 11082089 (work)
"...see you space cowboy..."