User Tools

Site Tools


finding_20the_20cpu_20usage

This is an old revision of the document!


A PCRE internal error occured. This might be caused by a faulty plugin

=====Finding the CPU usage===== //by Richard Russell, October 2011//\\ \\ The code listed below reports, once per second, the current total CPU usage:\\ *FLOAT 64 DIM IdleTime{l%,h%}, KernelTime{l%,h%}, UserTime{l%,h%} idletime = 0 kerneltime = 0 usertime = 0 REPEAT WAIT 100 SYS "GetSystemTimes", IdleTime{}, KernelTime{}, UserTime{} oldidletime = idletime oldkerneltime = kerneltime oldusertime = usertime idletime = IdleTime.h% * 2^32 + (IdleTime.l% >>> 1)*2 kerneltime = KernelTime.h% * 2^32 + (KernelTime.l% >>> 1)*2 usertime = UserTime.h% * 2^32 + (UserTime.l% >>> 1)*2 idledelta = idletime-oldidletime kerneldelta = kerneltime-oldkerneltime userdelta = usertime-oldusertime cpuusage = (userdelta+kerneldelta-idledelta)/(userdelta+kerneldelta) PRINT "CPU usage = ";INT(100*cpuusage+0.5) "%" UNTIL FALSE

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
finding_20the_20cpu_20usage.1522502360.txt.gz · Last modified: 2018/03/31 14:19 by 127.0.0.1