Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reducing the refresh rate of CPU Load input of the Host Info patch



The Host Info patch may be easy on the processor but the values coming out
of "CPU 1 Load" and "CPU 2 Load" refresh so many times a second that the
rest of my composition (which depends on the CPU Load values) get
re-evaluated too many times a second, thus the high processor usage.


I'm looking to throttle the CPU Load values, I only need a value about once
a second. Any ideas ?

You cannot control directly how often the Host Info patch updates the CPU Load. It actually updates them every time is runs, which is once per frame per default, so everything that depends on those values updates once per frame as well.


The only solution I can think of is to put a JavaScript patch between the Host Info patch and the rest of the pipeline to act as a gate that would let values pass every now and then. The JS could have an input for the CPU load and another one for the current time from Patch Time and two outputs with the "sampled" CPU load and the sampling time. Then you write a script like the following to sample every second (off the top of my head):

var time = inputs[1];

if((time >= outputs[1]) || (outputs[0] == undefined)) {
    outputs[0] = inputs[0]; //"load" is on inputs[0]
    outputs[1] = Math.floor(time + 1);
}

________________________________________________________
Pierre-Olivier Latour                            email@hidden
Quartz Composer Architect                Graphics & Imaging Team

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.