[comp.sys.mac.programmer] profiling and speeding up Mac code

Lawson.English@p88.f15.n300.z1.fidonet.org (Lawson English) (02/11/91)

Kevin Michael Goldsmith writes in a message to All

KMG> I already know a bit about speeding up C code. Also, is there 
KMG> any sort of profiler that I can use to see where the mac is spending 
KMG> time in my code?

M'boss and I wrote a profiler some time ago (it broke with system 5.x if that
gives you aan idea of how long ago). The largest single bottleneck for the average
Mac Program is the trap dispatcher. Most people don't like to use it, but if
you have graphics-intensive code that uses lots of "pixel-plots" then you might
consider using it. Another fine bottleneck is overuse of the "spinning beachball"
ICON. If you let that thing turn every so many widgets, the faster the CPU,
the proportionately greater the overhead to use it. If you are doing math-intensive
stuff and aren't calling the FPP directly, you might consider jumping directly
to the Package, or, better (if you don't need SANE's accuracy), patch the SANE
Package to call the FFP for ALL math functions, instead of just the arithmatic
ones (of course, then you have to handle the SANE/IEEE conversions yourself,
but...). 


Hope this helps...


Lawson
 

--  
Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!300!15.88!Lawson.English
Internet: Lawson.English@p88.f15.n300.z1.fidonet.org

han@Apple.COM (Byron Han) (02/12/91)

In article <EbhKsjq00UgKBE50l=@andrew.cmu.edu> kg1a+@andrew.cmu.edu (Kevin Michael Goldsmith) writes:
>I am currently working on some programs for my SE, and I am having
>problems with the speed.  Are there any "standard" speed up tricks for
>the Mac?  I already know a bit about speeding up C code.  Also, is there
>any sort of profiler that I can use to see where the mac is spending
>time in my code?
>
MPW ships with some code profiling libraries - I have used them to good effect.
-- 
Byron Han, Software Artist           "This space for rent..."             
Apple Computer, Inc.                 -----------------------------------------
20525 Mariani Ave, MS: 35CP          Internet: han@apple.COM
Cupertino, CA 95014                  UUCP:{sun,voder,nsc,decwrl}!apple!han
ATTnet: 408-974-6450                 Applelink:HAN1   HAN1@applelink.apple.COM

oster@well.sf.ca.us (David Phillip Oster) (02/15/91)

In article <2196.27B7FD50@stjhmc.fidonet.org> Lawson.English@p88.f15.n300.z1.fidonet.org (Lawson English) writes:
>Another fine bottleneck is overuse of the "spinning beachball"
>ICON. If you let that thing turn every so many widgets, the faster the CPU,
>the proportionately greater the overhead to use it.

I don't understand. If you crank the beachball every time you've done 100th
of the work, and it takes a 1000th of the total CPU time each time you
crank it, how does speeding up the CPU change these ratios?
-- 
-- David Phillip Oster - At least the government doesn't make death worse.
-- oster@well.sf.ca.us = {backbone}!well!oster

lsr@Apple.COM (Larry Rosenstein) (02/16/91)

In article <23166@well.sf.ca.us> oster@well.sf.ca.us (David Phillip Oster) writes:
>
>I don't understand. If you crank the beachball every time you've done 100th
>of the work, and it takes a 1000th of the total CPU time each time you
>crank it, how does speeding up the CPU change these ratios?

It depends on what you want to convey.  If you want to show how fast the
program is running then you're correct.  On a faster machines the
appropriate checkpoints occur faster and the beachball turns faster.

If the goal is just demonstrate progress, and run in the background (but not
show how fast progress is being made), then it is better to rotate the
cursor based on ticks.  Each time the cursor changes, MPW yields the CPU to
background tasks.  The more often the cursor changes the less CPU time the
tool gets.


-- 
		 Larry Rosenstein,  Object Specialist
 Apple Computer, Inc.  20525 Mariani Ave, MS 3-PK  Cupertino, CA 95014
	    AppleLink:Rosenstein1    domain:lsr@Apple.COM
		UUCP:{sun,voder,nsc,decwrl}!apple!lsr

Lawson.English@p88.f15.n300.z1.fidonet.org (Lawson English) (02/17/91)

David Phillip Oster writes in a message to All

DPO> I don't understand. If you crank the beachball every time you've 
DPO> done 100th of the work, and it takes a 1000th of the total CPU 
DPO> time each time you crank it, how does speeding up the CPU change 
DPO> these ratios

It depends on the hardware/software that is drawing the beachball. It doesn't
necessarily follow that 1/1000 of the CPU time on one Mac to draw the ball is
the same as 1/1000 of the time on another, or on the same Mac with an accellerator.
If you are actually doing 1 turn every 1000 widgets, there probably won't be
a problem, but some programs seem to spin the little ball so fast that it looks
like a blur. The little ball might be eating 50% (or more) of your time at that
speed.

Tom Dowdy pointed out to me that the "when" field of the EventRecord can be
used to time the turns of the cursor. If you don't want to call GetNextEvent
then TickCount might be used.


Lawson
 

--  
Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!300!15.88!Lawson.English
Internet: Lawson.English@p88.f15.n300.z1.fidonet.org