Jump to content

Latop CPU speed value changes


Recommended Posts

I have the following simple script that gives me info about the CPU of the computer my script is running on. However I have just started to run the script on a pentium mobile laptop and the value given by the script is not the same as the maximum. The processor is rated at 1.5Ghz but the value returned can sometimes be as low as 599Mhz.

Is ther a way that I can get the maximum value of the processor rather than the current value that it is running at?

$cpu = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "~MHz")
$cpumake = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "VendorIdentifier")
$cputype = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "Identifier")
FileWriteLine("C:\cpu.txt", "CPU Speed & Make = " & $cpu & " MHz " & $cpumake &" - "&$cputype& @CRLF
Link to comment
Share on other sites

requires beta

MsgBox(0, "Clock Speed", _GetClockSpeed(@ComputerName))

Func _GetClockSpeed($s_Machine)
    Local Const $wbemFlagReturnImmediately = 0x10
    Local Const $wbemFlagForwardOnly = 0x20
    Local $objWMIService = ObjGet("winmgmts:\\" & $s_Machine & "\root\CIMV2")
    Local $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Processor", "WQL", _
            $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    If @error Then
        MsgBox(16, "_GetClockSpeed", "ExecQuery Error: SELECT * FROM Win32_Processor")
        Return
    EndIf
    
    Local $s_info = "", $objItem
    If IsObj($colItems) Then
        For $objItem In $colItems
            If $objItem.MaxClockSpeed > 999 Then
                $s_info = StringFormat("%1.2f", $objItem.MaxClockSpeed / 1000) & " GHz"
            Else
                $s_info = $objItem.MaxClockSpeed & " MHz"
            EndIf
        Next
    EndIf
    Return $s_info
EndFunc   ;==>_GetClockSpeed

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Thanks for that it has set me off on the right path. But the script seems to be giving me an incorrect value. Unfortunately I do not have the laptop to hand but I ran some tests using a 996Mhz pentium 3. I hacked the registry entry that I checked in my previous script for the processor speed so that it read 1996. The script posted above then gave me 2 Ghz which seems like the script is checking the same value as my registry reading script.

I then made a change and instead of looking for the max clock speed value I checked the current clock speed value. This gave 1 Ghz which is correct.

MsgBox(0, "Clock Speed", _GetClockSpeed(@ComputerName))

Func _GetClockSpeed($s_Machine)
    Local Const $wbemFlagReturnImmediately = 0x10
    Local Const $wbemFlagForwardOnly = 0x20
    Local $objWMIService = ObjGet("winmgmts:\\" & $s_Machine & "\root\CIMV2")
    Local $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Processor", "WQL", _
            $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    If @error Then
        MsgBox(16, "_GetClockSpeed", "ExecQuery Error: SELECT * FROM Win32_Processor")
        Return
    EndIf
    
    Local $s_info = "", $objItem
    If IsObj($colItems) Then
        For $objItem In $colItems
            If $objItem.CurrentClockSpeed > 999 Then
                $s_info = StringFormat("%1.2f", $objItem.CurrentClockSpeed/ 1000) & " GHz"
            Else
                $s_info = $objItem.CurrentClockSpeed & " MHz"
            EndIf
        Next
    EndIf
    Return $s_info
EndFunc  ;==>_GetClockSpeed

Surely the max speed wouldn't be that entered in the registry?

Link to comment
Share on other sites

Your lovely exe did not work on my 2000SP4 machine the dropdowns did not have anything in them. But I tried with XP SP2 and they worked fine. Very nice application by the way. However it gave the same values for max and current clock speed and completely ignored what was entered in the registry. As I said I could not run it on my 2000 machine.

I did some more investigation using my script above and noticed that when I edit the registry to give a lesser Mhz than the processor actually is I get MaxClockSpeed returning the registry value and CurrentClockSpeed gives the registry value too. If I edit the registry to give higher than the CPU clock then MaxClockSpeed gives the registry entry (which is the highest of the two) and CurrentClockSpeed gives the actual speed.

Is there a difference between the WMI on 2000 and that on XP hence the differences in results and also the fact that the scriptomatic.exe would not run? Why does the scriptomatic.exe always return the correct cpu value whatever the registry says?

I am very confused.

Edited by Lee Evans
Link to comment
Share on other sites

  • 7 months later...

To expand on the issue of processor speeds: How would you slow the processor speed during execution of a script. I have a script that definitely needs sleep time due to being run on a slower machine. I want to test at a slower speed than the machine I am developing on to insure it will function on the older machine without having to physically test on the slower machines. Any help with this type of coing would be grateful.

Link to comment
Share on other sites

To expand on the issue of processor speeds: How would you slow the processor speed during execution of a script. I have a script that definitely needs sleep time due to being run on a slower machine. I want to test at a slower speed than the machine I am developing on to insure it will function on the older machine without having to physically test on the slower machines. Any help with this type of coing would be grateful.

u can try running some other demanding application simultaneously. This will reduce the processor time available for your application giving it the feel of running on a slower computer.

Link to comment
Share on other sites

I've a laptop and I've noticed something. Laptop's dynamically set their clock speed. Everyone knows that. But here's how you can control what speed it runs at:

- To slow down the processor, put the machine into standby and bring it back.

- To speed up (ensure battery is inserted), turn off the AC power supply, wait 1 second and turn AC power supply on again.

This will make a difference when you are playing games or watching HD video... check it out...

Link to comment
Share on other sites

I've a laptop and I've noticed something. Laptop's dynamically set their clock speed. Everyone knows that. But here's how you can control what speed it runs at:

- To slow down the processor, put the machine into standby and bring it back.

- To speed up (ensure battery is inserted), turn off the AC power supply, wait 1 second and turn AC power supply on again.

This will make a difference when you are playing games or watching HD video... check it out...

I prefer to use this tool: http://www.diefer.de/speedswitchxp/index.html

EDIT: Don't forget powercfg.exe (comes with WinXP SP2).

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

On a laptop, you can always throttle Speedstep (or PowerNow if you're using an AMD chip) the correct way by using the Power Options control panel applet. The "Always On" profile will keep your chip throttled at maximum all the time. Some of the other profiles will throttle you down to slower speeds to save on power consumption, which is helpful when you're using your laptop on battery power.

When playing games or watching HD video, set your laptop's power profile to "Always On."

-S

(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]
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...