Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

hob

macrumors 68010
Original poster
Oct 4, 2003
2,004
0
London, UK
Hi everyone.

I've written some compositions in Quartz Composer and want to demonstrate how they tax the CPU in various conditions.

I've opened up Instruments and I can get it to give me a readout for the individual process (Quartz Composer) but I can't see any obvious way to average the CPU load... I can see the peaks, but I'd much rather know what the average is over 1 minute, in this instance (I want to compare different compositions - there's no variables within them as such...)

I found a little DTrace script in the apple docs, but couldn't really get it to work... it would quit with an error after about 45 seconds...

Anyone got any ideas?
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
Haven't made the leap to Leopard yet, so I can't comment on Instruments, but:

date ; ps -aux | grep PID | grep -v grep | awk '{print $10}'; sleep 60 ;date;ps -aux | grep PID | grep -v grep | awk '{print $10}'

Replace PID with the PID you want to monitor.

You'll have to do some math yourself. There's probably a way to subtract the first cpu time from the second, then divide by .6 to get the precentage used, but you can at least do those 2 calculations yourself now to get what you're looking for.

-Lee
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
Run uptime for a baseline, run the thing for one minute, take uptime again.

I think that will only give the one, five, and fifteen minute load averages. Even with the minutely load average this says very little about the CPU usage of the process in question. I may be misinterpreting but this seems to, at best, give a general trend of system load, which most definitely should trend up when an additional task is added.

-Lee
 

GeeYouEye

macrumors 68000
Dec 9, 2001
1,669
10
State of Denial
I think that will only give the one, five, and fifteen minute load averages. Even with the minutely load average this says very little about the CPU usage of the process in question. I may be misinterpreting but this seems to, at best, give a general trend of system load, which most definitely should trend up when an additional task is added.

-Lee

Could be I'm misinterpreting the problem, but that sounds about what's right; assuming nothing but the target process is running, the two one-minute averages subtracted ought to give some idea of the system load for the target process.
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
It would probably be difficult to keep everything else on the system at bay during the test. There are plenty of background processes whose activity may vary during the test, etc.

Since the load average is based on the length of the run queue and the number of running processes, the amount of CPU the process is actually using may have little or no effect on the load average. The fact that there is one more process may slightly affect the average, but how much CPU it uses may not. The relative impact on load average of different programs may give you some indication of which is more intensive, but not necessarily.

We're both interpreting the request slightly differently, so the OP might want to clarify. "how they tax the CPU", "average the CPU load", and "the average is over 1 minute" are pretty wide open in terms of what you want. What I provided allows for computation of the average % of a single CPU core over the minute is, what GeeYouEye provided will allow you to get a general idea of impact on the system. Either of these may fit the need, or they might both miss the target.

-Lee
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.