html>AutoHotkey Benchmarks

AutoHotkey Benchmarks

Contents

Control Group

BenchmarkCodeAverage time per run (ms)
Blank Run
(None)
0.001013

1,000,000 iterations each

Assignment

BenchmarkCodeAverage time per run (ms)
Classic
Variable = Lorem ipsum dolor sit amet
0.001431
Classic with variable
Variable = Lorem ipsum %OtherVariable% dolor sit amet
0.001591
Expression
Variable := "Lorem ipsum dolor sit amet"
0.001684
Expression with variable
Variable := "Lorem ipsum" . OtherVariable . " dolor sit amet"
0.002148
Expression explicit concatenation
Variable := "Lorem ipsum" . " dolor sit amet"
0.001972
Expression implicit concatenation
Variable := "Lorem ipsum" " dolor sit amet"
0.002055

1,000,000 iterations each

Comparison

BenchmarkCodeAverage time per run (ms)
Classic If statement
If Variable = abcdef
 Return
0.002063
Expression If statement
If (Variable = "abcdef")
 Return
0.002184
List comparison
If Variable In abcdef
 Return
0.002305
Ternary
% (Variable = "abcdef") ? "" : ""
0.002482
Classic If between
If Variable Between 123 And 124
 Return
0.002479
Expression If between
If (Variable >= 123 && Variable <= 124)
 Return
0.003127

1,000,000 iterations each

String Searching

BenchmarkCodeAverage time per run (ms)
String search statement
IfInString, Variable, abcdef
 Return
0.002761
List search statement
If Variable Contains abcdef
 Return
0.002938
String get position command
StringGetPos, Temp1, Variable, abcdef
0.003210
In string function
InStr(Variable,"abcdef")
0.003173

1,000,000 iterations each

Regular Expressions

BenchmarkCodeAverage time per run (ms)
Match function
RegExMatch(Variable,"S)ab.*?.f$")
0.003509
Replace function
RegExReplace(Variable,"S)ab.*?.f$","$0")
0.003756
Static match
RegExMatch(Variable,"S)abcdef")
0.003482
Static replace
RegExReplace(Variable,"c","c")
0.005639

500,000 iterations each

String Manipulation

BenchmarkCodeAverage time per run (ms)
Substring function
SubStr(Variable,2,3)
0.003442
String middle command
StringMid, Temp1, Variable, 2, 3
0.004074
String trim command
StringTrimLeft, Temp1, Variable, 1
0.004000
String replace command
StringReplace, Temp1, Variable, c, c, All
0.004894

1,000,000 iterations each

String Operations

BenchmarkCodeAverage time per run (ms)
String length function
StrLen(Variable)
0.003737
String length command
StringLen, Temp1, Variable
0.003972
String split command
StringSplit, Temp, Variable, c
0.005224
Case conversion
StringUpper, Temp1, Variable
0.004331

1,000,000 iterations each

Files

BenchmarkCodeAverage time per run (ms)
File attributes and exists function
FileExist(A_ScriptFullPath)
0.066415
If file exists
IfExist, %A_ScriptFullPath%
 Return
0.066237
Get size
FileGetSize, Temp1,%A_ScriptFullPath%
0.085373
Read file
FileRead, Temp1, *m100 %A_ScriptFullPath%
0.120058
Read file line
FileReadLine, Temp1, %A_ScriptFullPath%, 2
0.123659
Append to file
FileAppend, c, %A_Temp%\Temp.txt
3.450006
Copy file
FileCopy, %A_Temp%\Temp.txt, %A_Temp%\Temp1.txt, 1
2.133724
Move file
FileMove, %A_Temp%\Temp.txt, %A_Temp%\Temp.txt, 1
1.869614
Filesystem loop
Loop, %A_ScriptFullPath%
 Return
0.086202
File reading loop
Loop, Read, %A_ScriptFullPath%
 Return
0.118976

5,000 iterations each

Control Flow

BenchmarkCodeAverage time per run (ms)
Normal loop
Loop, 1
{
 
}
0.005538
While loop
While, (A_Index = 1)
{
 
}
0.005665
Parsing loop
Loop, Parse, Variable, ,
{
 
}
0.006263
Blank subroutine call
Gosub, BlankLabel
0.005234
Blank function call
BlankFunction()
0.005615

1,000,000 iterations each

Environment Variables

BenchmarkCodeAverage time per run (ms)
Set environment variable
EnvSet, EnvVar, abcdeg
0.011371
Get environment variable
EnvGet, Temp1, EnvVar
0.006105

500,000 iterations each

Keyboard and mouse

BenchmarkCodeAverage time per run (ms)
Get mouse position
MouseGetPos, Temp1, Temp2
0.008552
Move mouse
MouseMove, 0, 0, 0, R
0.200388

10,000 iterations each

Dynamic Variables

BenchmarkCodeAverage time per run (ms)
Dynamic variable access
% %Variable%
0.006127
Dynamic variable assignment
%Variable% = abcdeg
0.006038

1,000,000 iterations each

System Information

FieldValue
AutoHotkey VersionAutoHotkey v1.1.05.06 Unicode (x86)
OS NameMicrosoft Windows 7 Home Premium
OS Version6.1.7601 Service Pack 1 Build 7601
OS ConfigurationStandalone Workstation
OS Build TypeMultiprocessor Free
System ManufacturerTOSHIBA
System ModelSatellite C655D
System Typex64-based PC
Processor(s)1 Processor(s) Installed.,[01]: AMD64 Family 20 Model 1 Stepping 0 AuthenticAMD ~1600 Mhz
BIOS VersionInsyde Corp. 1.60, 6/23/2011
Total Physical Memory2,663 MB
Available Physical Memory993 MB
Virtual Memory: Max Size5,324 MB
Virtual Memory: Available2,770 MB