Jump to content

computerSpeedTest() + superSleep() = variable script speed


ddxfish
 Share

Recommended Posts

Variable Sleep() times to adjust for slow computers with basic a speed test to automate the slowness calculation.

Notes:

  • IMPORTANT: This must be compiled with "Require admin rights" to run because it is a tool in system32!
  • The speed test measures hard drive speed only! (I find I use Sleep to wait for hard drive most often)
  • You need to set  Global $slownessFactor = 1  in the beginning of the script for superSleep() to work before the computerSpeedTest()
  • I have not tested this on XP or Vista
  • Run computerSpeedTest() at the beginning of any script, and you can call superSleep() until the script closes

 

computerSpeedTest() will run a disk speed check that takes about 1 minute on a fast computer. It times the length of the test, then gives the script a "slownessFactor" variable of 1 to 10 based on the number of minutes to run the test.

Func computerSpeedTest()
    Local $speedtimer = TimerInit()
    Local $pid = Run("winsat disk -drive " & @HomeDrive)
    supersleep(10000)
    While WinExists("C:\Windows\system32\winsat.exe")
        superSleep(1000)
    WEnd
    Local $speedresult = ((TimerDiff($speedtimer) / 1000) / 60)
    ;sanity checks
    If $speedresult < 1 Then
        $speedresult = 1
    ElseIf $speedresult > 10 Then
        $speedresult = 10
    Else ;round to higher integer
        $speedresult = Ceiling($speedresult)
    EndIf
    ;set global result
    Global $slownessFactor = $speedresult
    supersleep(250)
    Return $speedresult
EndFunc   ;==>computerSpeedTest

superSleep() will replace Sleep() and will multiply the Sleep value by the slownessFactor variable.

;Modifies sleep time based on computer speed
Func superSleep($sleeptime)
    Sleep($sleeptime * $slownessFactor)
EndFunc   ;==>superSleep
Edited by ddxfish
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...