CPU usage

Hi all,

I'm using python and psutil a library to get system informations like cpu usage (percent) for a given process.
My question is if I have the value in % of the cpu usage how I could get the cpu usage in cycle number I mean not in percent?

Thanks a lot

D.

What does 'cycle number' even mean on a modern machine where different instructions take a different number of cycles and the CPU clock speed itself may vary over time?

Try psutil.process get_cpu_times which returns a tuple.

You can then get the sum of cpu speed x each element of the tuple. That gives you cycles. psutil does not return cpu speed AFAIK or so the docset says. You can read the /proc/cpuinfo "file" on linux to get that information.

yea sorry,

I meant that I would like to evaluate the load that a given process bring to the CPU but not in percent.
I'm giving a look around and found that I should refer to user time, system time, start time and current time for the given process and use:

(user-time+system-time)/(current time - start time)

D.

@corona - I think the OP wants a generalized solution - your comment is completely correct, however.

I'll do

Thanks for help

D.