Function Reference


_WinAPI_QueryProcessCycleTime

Retrieves the sum of the cycle time of all threads of the specified process

#include <WinAPISys.au3>
_WinAPI_QueryProcessCycleTime( $iPid = 0 )

Parameters

$iPid Pid of the process (Default = @AutoItPID)
Success: The cycle time of the specified process.
Failure: Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search QueryProcessCycleTime in MSDN Library.

Example

#AutoIt3Wrapper_AutoIt3Dir = e:\trunk.SVN\Bin

#pragma compile(AutoItExecuteAllowed, True)

;~ #include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPISys.au3>

; create a script which use CPU
Local $sTestAu3 = @TempDir & "\TestSystemIdle.au3"
FileDelete($sTestAu3)
FileWriteLine($sTestAu3, 'For $i = 1 To 50000000')
FileWriteLine($sTestAu3, '$i = $i')
FileWriteLine($sTestAu3, 'Next')

Local $fFrequency = 1.0 / _WinAPI_QueryPerformanceFrequency() * 4 ; 4 is the number of CPU and the run script only execute on 1

Local $iPid
If @Compiled Then
    $iPid =  Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & $sTestAu3 & '"')
Else
    $iPid =  Run(@AutoItExe & " " & $sTestAu3)
EndIf

Sleep(2000)
Local $nTickCount = Round(_WinAPI_QueryProcessCycleTime($iPid) * $fFrequency, 2)

ProcessClose($iPid)
FileDelete($sTestAu3)

MsgBox($MB_TOPMOST, 'Test TickCount', $nTickCount & " msec") ; not equal to 2000 as the run script does not get CPU allocation all the time