erik501 Posted May 22, 2023 Posted May 22, 2023 Good morning I would need a function to detect it dynamic speed of the processor, all the tests I did give me the maximum fixed speed read in the bios and not the speed to which the processor is turning. Any indication to direct me in the right direction? Thank you
Andreik Posted May 22, 2023 Posted May 22, 2023 What is dynamic speed of the processor? Are you talking about CPU throttling?
mistersquirrle Posted May 22, 2023 Posted May 22, 2023 I believe that they're looking for is the current CPU speed/frequency, which you can see in Task Manager, for example: I tried several methods, and the best I could get to return was the base speed of 3800 MHz, I could not get it to return the ~4200 MHz that my CPU was actually running at. I tried WMI and registry ways successfully with values. I also tried through pdh.dll (performance counters) and powrprof.dll (CallNtPowerInformation) however I wasn't able to get data back from either. From what I saw, I don't think that it's really possible from AutoIt at least to get this information. WMI: #include <Array.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> Local $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\.\root\cimv2") If Not IsObj($objWMIService) Then ConsoleWrite("Failed to retrieve WMI service object." & @CRLF) Exit EndIf Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", 0x30) If Not IsObj($colItems) Then ConsoleWrite("Failed to query WMI for processor information." & @CRLF) Exit EndIf For $objItem In $colItems ConsoleWrite("Current CPU Frequency: " & $objItem.CurrentClockSpeed & " MHz" & @CRLF) ConsoleWrite("CPU MaxClockSpeed: " & $objItem.MaxClockSpeed & " MHz" & @CRLF) Next Registry: #include <WinAPIReg.au3> Local $cpuFrequency = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "~MHz") If @error Then ConsoleWrite("Failed to read CPU frequency from the registry." & @CRLF) Exit EndIf ConsoleWrite("Current CPU Frequency: " & $cpuFrequency & " MHz" & @CRLF) We ought not to misbehave, but we should look as though we could.
Andreik Posted May 22, 2023 Posted May 22, 2023 As far as I know you can't directly get that info, it's a calculated value. Maybe some approximation value might be obtained using rdtsc but for an accurate value you need a driver with privileges to read MSRs.
erik501 Posted May 22, 2023 Author Posted May 22, 2023 Thanks, as I thought, from the tests I've done I can only get the maximum speed of the cpu
erik501 Posted May 27, 2023 Author Posted May 27, 2023 I made the insertion of the throttling of the CPU and the temperature for my purpose using Coretemp Shared Memory if someone is interested in the entire script.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now