AutoHotkey Benchmarks

Contents

Control Group

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

1,000,000 iterations each

Assignment

BenchmarkCodeAverage time per run (ms)
Classic
Variable = Lorem ipsum dolor sit amet
0.000557
Classic with variable
Variable = Lorem ipsum %OtherVariable% dolor sit amet
0.000623
Expression
Variable := "Lorem ipsum dolor sit amet"
0.000754
Expression with variable
Variable := "Lorem ipsum" . OtherVariable . " dolor sit amet"
0.000935
Expression explicit concatenation
Variable := "Lorem ipsum" . " dolor sit amet"
0.000883
Expression implicit concatenation
Variable := "Lorem ipsum" " dolor sit amet"
0.000918

1,000,000 iterations each

Comparison

BenchmarkCodeAverage time per run (ms)
Classic If statement
If Variable = abcdef
 Return
0.000834
Expression If statement
If (Variable = "abcdef")
 Return
0.000933
List comparison
If Variable In abcdef
 Return
0.000937
Ternary
% (Variable = "abcdef") ? "" : ""
0.001058
Classic If between
If Variable Between 123 And 124
 Return
0.001002
Expression If between
If (Variable >= 123 && Variable <= 124)
 Return
0.001207

1,000,000 iterations each

String Searching

BenchmarkCodeAverage time per run (ms)
String search statement
IfInString, Variable, abcdef
 Return
0.001102
List search statement
If Variable Contains abcdef
 Return
0.001176
String get position command
StringGetPos, Temp1, Variable, abcdef
0.001292
In string function
InStr(Variable,"abcdef")
0.001289

1,000,000 iterations each

Regular Expressions

BenchmarkCodeAverage time per run (ms)
Match function
RegExMatch(Variable,"S)ab.*?.f$")
0.001453
Replace function
RegExReplace(Variable,"S)ab.*?.f$","$0")
0.001516
Static match
RegExMatch(Variable,"S)abcdef")
0.001462
Static replace
RegExReplace(Variable,"c","c")
0.001914

500,000 iterations each

String Manipulation

BenchmarkCodeAverage time per run (ms)
Substring function
SubStr(Variable,2,3)
0.001441
String middle command
StringMid, Temp1, Variable, 2, 3
0.001596
String trim command
StringTrimLeft, Temp1, Variable, 1
0.001541
String replace command
StringReplace, Temp1, Variable, c, c, All
0.001939

1,000,000 iterations each

String Operations

BenchmarkCodeAverage time per run (ms)
String length function
StrLen(Variable)
0.001564
String length command
StringLen, Temp1, Variable
0.001575
String split command
StringSplit, Temp, Variable, c
0.002082
Case conversion
StringUpper, Temp1, Variable
0.001778

1,000,000 iterations each

Files

BenchmarkCodeAverage time per run (ms)
File attributes and exists function
FileExist(A_ScriptFullPath)
0.019263
If file exists
IfExist, %A_ScriptFullPath%
 Return
0.017952
Get size
FileGetSize, Temp1,%A_ScriptFullPath%
0.026075
Read file
FileRead, Temp1, *m100 %A_ScriptFullPath%
0.040066
Read file line
FileReadLine, Temp1, %A_ScriptFullPath%, 2
0.040645
Append to file
FileAppend, c, %A_Temp%\Temp.txt
0.786217
Copy file
FileCopy, %A_Temp%\Temp.txt, %A_Temp%\Temp1.txt, 1
0.349792
Move file
FileMove, %A_Temp%\Temp.txt, %A_Temp%\Temp.txt, 1
0.216756
Filesystem loop
Loop, %A_ScriptFullPath%
 Return
0.027141
File reading loop
Loop, Read, %A_ScriptFullPath%
 Return
0.039999

5,000 iterations each

Control Flow

BenchmarkCodeAverage time per run (ms)
Normal loop
Loop, 1
{
 
}
0.002012
While loop
While, (A_Index = 1)
{
 
}
0.002181
Parsing loop
Loop, Parse, Variable, ,
{
 
}
0.002288
Blank subroutine call
Gosub, BlankLabel
0.002104
Blank function call
BlankFunction()
0.002170

1,000,000 iterations each

Environment Variables

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

500,000 iterations each

Keyboard and mouse

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

10,000 iterations each

Dynamic Variables

BenchmarkCodeAverage time per run (ms)
Dynamic variable access
% %Variable%
0.002465
Dynamic variable assignment
%Variable% = abcdeg
0.002347

1,000,000 iterations each

System Information

FieldValue
AutoHotkey VersionAutoHotkey v1.1.05.06 Unicode (x86)
OS NameMicrosoft Windows 7 Professional
OS Version6.1.7601 Service Pack 1 Build 7601
OS ConfigurationStandalone Workstation
OS Build TypeMultiprocessor Free
System ManufacturerGigabyte Technology Co., Ltd.
System ModelP55-USB3
System Typex64-based PC
Processor(s)1 Processor(s) Installed.,[01]: Intel64 Family 6 Model 30 Stepping 5 GenuineIntel ~2798 Mhz
BIOS VersionAward Software International, Inc. F9, 11/1/2010
Total Physical Memory16,375 MB
Available Physical Memory12,970 MB
Virtual Memory: Max Size40,923 MB
Virtual Memory: Available36,886 MB