Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 17, 2008, 04:30 PM   #1
hob
macrumors 68020
 
hob's Avatar
 
Join Date: Oct 2003
Location: London, UK
Instruments: Average CPU Load over one minute

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?
__________________
see robmac.net for my work

Last edited by hob; Apr 17, 2008 at 04:38 PM.
hob is offline   0 Reply With Quote
Old Apr 21, 2008, 08:59 PM   #2
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: 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

Last edited by lee1210; Apr 22, 2008 at 01:13 AM. Reason: stupid spelling error
lee1210 is offline   0 Reply With Quote
Old Apr 22, 2008, 12:56 AM   #3
GeeYouEye
macrumors 68000
 
GeeYouEye's Avatar
 
Join Date: Dec 2001
Location: State of Denial
Send a message via AIM to GeeYouEye Send a message via Yahoo to GeeYouEye
Run uptime for a baseline, run the thing for one minute, take uptime again.
__________________
I bring order to chaos. You are in chaos Windows, you are the contradiction, a bug wishing to be an OS.
Visit Softyards Software
NEW DEFINITION OF GEEK
Like politics, free speech, computers, entertainment, and more? Join us at Wordforge.net
GeeYouEye is offline   0 Reply With Quote
Old Apr 22, 2008, 01:11 AM   #4
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: Dallas, TX
Quote:
Originally Posted by GeeYouEye View Post
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
lee1210 is offline   0 Reply With Quote
Old Apr 22, 2008, 12:04 PM   #5
GeeYouEye
macrumors 68000
 
GeeYouEye's Avatar
 
Join Date: Dec 2001
Location: State of Denial
Send a message via AIM to GeeYouEye Send a message via Yahoo to GeeYouEye
Quote:
Originally Posted by lee1210 View Post
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.
__________________
I bring order to chaos. You are in chaos Windows, you are the contradiction, a bug wishing to be an OS.
Visit Softyards Software
NEW DEFINITION OF GEEK
Like politics, free speech, computers, entertainment, and more? Join us at Wordforge.net
GeeYouEye is offline   0 Reply With Quote
Old Apr 22, 2008, 01:50 PM   #6
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: 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
lee1210 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
iPhone: SpringBoard drain battery (CPU load more 20%) sstyle Jailbreaks and iOS Hacks 8 May 8, 2014 11:39 AM
kernel_task high CPU load only when downloading reery OS X 10.8 Mountain Lion 5 Aug 9, 2013 05:48 AM
High Load Average Cause Heat TheLove OS X 1 Mar 3, 2013 05:43 AM
login items take more than a minute to load Nitrile OS X 10.8 Mountain Lion 1 Jul 26, 2012 10:26 AM
AirPlay - CPU load or pure streaming? job2 Mac OS X 10.7 Lion 3 Jul 6, 2012 12:48 PM

Forum Jump

All times are GMT -5. The time now is 01:08 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC