Re: How to get Total cpu usage
Re: How to get Total cpu usage
- Subject: Re: How to get Total cpu usage
- From: mm w <email@hidden>
- Date: Thu, 11 Jun 2009 10:59:18 -0700
Hi you did not make the effort to push your google button,
basically something like the following snap
but there are other options to estimate it for instance:
- you could popen vm_stat
- open "Activity Monitor"
- you may also be able to list all proc with sysctl familly
- getrusage
now it's in your hands: to find the most significant average calculus
uint32_t count;
processor_cpu_load_info_t info;
mach_msg_type_number_t message;
kern_return_t status = host_processor_info(
host, PROCESSOR_CPU_LOAD_INFO, &count,
&info,
&message
);
do {
// info[i].cpu_ticks[CPU_STATE_SYSTEM];
// info[i].cpu_ticks[CPU_STATE_USER];
// info[i].cpu_ticks[CPU_STATE_IDLE];
/* calculate your average */
} while (++i < count);
PS: NOT A KERNEL QUESTION
Best,
On Wed, Jun 10, 2009 at 10:52 PM, Mathu kannan<email@hidden> wrote:
> Hi,
>
> How to get Total cpu usage programmetically in MAC.
> Any API is there?
>
>
> Regards,
> Mathu.
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Darwin-kernel mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden