Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Script to benchmark load time of script interpreter programs:
- 'CMD (batch file), Windows Script Host (CSCRIPT; JScript & VBScript),
- 'AutoHotkey, and PowerShell.
- '
- 'Load time is the averate time to execute a test script file 50 times.
- 'Test script code is simply to set local variable `a` to text `z`.
- '
- 'Execute this script using CSCRIPT from the Command Prompt.
- '
- 'Result on 4-cores Intel i5 2.4GHz, 16GB RAM, Windows 7 SP1 x64,
- 'Internet Explorer 11, PowerShell 2.0:
- '
- 'CMD Batch File average load time: 35.94ms
- 'WSH JScript average load time: 49.9ms
- 'WSH VBScript average load time: 48.12ms
- 'AutoHotkey average load time: 35.48ms
- 'PowerShell average load time: 572.7ms
- '
- 'PowerShell lags behind miserably.
- testCount = 50
- 'name, result, cmdline, ext, code
- tests = array( _
- array("CMD Batch File", -1, "c:\windows\system32\cmd.exe /c", "bat", _
- "@set a=z"), _
- array("WSH JScript", -1, "c:\windows\system32\cscript.exe", "js", _
- "a = 'z'"), _
- array("WSH VBScript", -1, "c:\windows\system32\cscript.exe", "vbs", _
- "a = ""z"""), _
- array("AutoHotkey", -1, """c:\program files (x86)\text\autohotkey" & _
- "\autohotkey.exe""", "ahk", "a:= ""z"""), _
- array("PowerShell", -1, "c:\windows\system32\WindowsPowerShell\v1.0" & _
- "\powershell.exe -executionpolicy bypass", "ps1", _
- "set-variable a z" & vbcrlf) _
- )
- set fs = createobject("scripting.filesystemobject")
- for each r in tests
- if left(r(2), 1) = """" then
- s = mid(r(2), 2, instr(2, r(2), """") - 2)
- else
- s = left(r(2), instr(r(2), ".exe") + 3)
- end if
- if not fs.fileexists(s) then
- wsh.stdout.writeline "File is not found: " & s
- e = true
- end if
- next
- if e then wsh.quit
- set ws = createobject("wscript.shell")
- tp = fs.getspecialfolder(2) & "\test."
- wsh.stdout.writeline "Script load-times benchmark"
- for i = 0 to ubound(tests)
- wsh.stdout.writeline
- fn = tp & tests(i)(3)
- set f = fs.createtextfile(fn)
- f.write tests(i)(4)
- f.close
- t = timer
- for j = 1 to testCount
- wsh.stdout.writeline tests(i)(0) & " test " & j & " of " & testCount
- ws.run tests(i)(2) & " """ & fn & """", 0, true
- next
- tests(i)(1) = round(((timer - t) * 1000) / testCount, 3)
- fs.deletefile fn
- next
- wsh.stdout.writeline
- for each r in tests
- wsh.stdout.writeline r(0) & " average load time: " & r(1) & "ms"
- next
Add Comment
Please, Sign In to add comment