Jump to content

CPU Usage


tlokz
 Share

Recommended Posts

Ok looked through it and could get proccess info and such and mem usage but no CPU usage funcs

I need to check how much CPU usage a certain proccess is using

I'm not a noob I know it will spike but I will have a timer on it so if its at like 60+ for more then 20 secs it will kill process

Thnx in ahead

Link to comment
Share on other sites

Ok looked through it and could get proccess info and such and mem usage but no CPU usage funcs

I need to check how much CPU usage a certain proccess is using

I'm not a noob I know it will spike but I will have a timer on it so if its at like 60+ for more then 20 secs it will kill process

Thnx in ahead

Link to comment
Share on other sites

tlokz

Example:

$strComputer = "."
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")

While 1
    $StartTime = _GetProcTime("mplayerc.exe")
    Sleep(1000)
    $EndTime = _GetProcTime("mplayerc.exe")
    $total = Int(($EndTime - $StartTime) / 100000)
    ToolTip("mplayerc.exe used " & $total & "%", 10, 10, "CPU Usage")
WEnd

ToolTip("")

Func _GetProcTime($sProcName)
    If Not ProcessExists($sProcName) Then Return SetError(1, 0, 0)
    
    Local $colProcesses, $objProcess, $sngProcessTime
    
    $colProcesses = $objWMIService.ExecQuery("Select * from Win32_Process Where name = '" & $sProcName & "'")
    
    For $objProcess in $colProcesses
        $sngProcessTime = ($objProcess.KernelModeTime + $objProcess.UserModeTime)
    Next
    
    Return $sngProcessTime
EndFunc
Link to comment
Share on other sites

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...