Jump to content
Sign in to follow this  
tlokz

CPU Usage

Recommended Posts

tlokz

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

Share this post


Link to post
Share on other sites
tlokz

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

Share this post


Link to post
Share on other sites
rasim

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

Share this post


Link to post
Share on other sites
Andreik

Or you can use this function


When the words fail... music speaks

Share this post


Link to post
Share on other sites
boshi

yup. i notice too. when i run a game and using script i created using AutoIt, the game client freeze a few seconds when certain action taken. maybe because of the game is eating too much memory. ;)

Share this post


Link to post
Share on other sites
dbzfanatic

Share this post


Link to post
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
Sign in to follow this  

×