AutoHotkey Benchmarks

Contents

Control Group

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

1,000,000 iterations each

Assignment

BenchmarkCodeAverage time per run (ms)
Classic
Variable = Lorem ipsum dolor sit amet
0.001756
Classic with variable
Variable = Lorem ipsum %OtherVariable% dolor sit amet
0.002428
Expression
Variable := "Lorem ipsum dolor sit amet"
0.003179
Expression with variable
Variable := "Lorem ipsum" . OtherVariable . " dolor sit amet"
0.002960
Expression explicit concatenation
Variable := "Lorem ipsum" . " dolor sit amet"
0.003474
Expression implicit concatenation
Variable := "Lorem ipsum" " dolor sit amet"
0.002854

1,000,000 iterations each

Comparison

BenchmarkCodeAverage time per run (ms)
Classic If statement
If Variable = abcdef
 Return
0.004059
Expression If statement
If (Variable = "abcdef")
 Return
0.003540
List comparison
If Variable In abcdef
 Return
0.003933
Ternary
% (Variable = "abcdef") ? "" : ""
0.004313
Classic If between
If Variable Between 123 And 124
 Return
0.004414
Expression If between
If (Variable >= 123 && Variable <= 124)
 Return
0.006011

1,000,000 iterations each

String Searching

BenchmarkCodeAverage time per run (ms)
String search statement
IfInString, Variable, abcdef
 Return
0.005424
List search statement
If Variable Contains abcdef
 Return
0.005466
String get position command
StringGetPos, Temp1, Variable, abcdef
0.006120
In string function
InStr(Variable,"abcdef")
0.004821

1,000,000 iterations each

Regular Expressions

BenchmarkCodeAverage time per run (ms)
Match function
RegExMatch(Variable,"S)ab.*?.f$")
0.007863
Replace function
RegExReplace(Variable,"S)ab.*?.f$","$0")
0.007752

500,000 iterations each

String Manipulation

BenchmarkCodeAverage time per run (ms)
Substring function
SubStr(Variable,2,3)
0.006287
String middle command
StringMid, Temp1, Variable, 2, 3
0.006806
String trim command
StringTrimLeft, Temp1, Variable, 1
0.005870
String replace command
StringReplace, Temp1, Variable, c, c, All
0.007410

1,000,000 iterations each

String Operations

BenchmarkCodeAverage time per run (ms)
String length function
StrLen(Variable)
0.005941
String length command
StringLen, Temp1, Variable
0.006281
String split command
StringSplit, Temp, Variable, c
0.010252
Case conversion
StringUpper, Temp1, Variable
0.009812

1,000,000 iterations each

Files

BenchmarkCodeAverage time per run (ms)
File attributes and exists function
FileExist(A_ScriptFullPath)
0.104791
If file exists
IfExist, %A_ScriptFullPath%
 Return
0.111106
Get size
FileGetSize, Temp1,%A_ScriptFullPath%
0.147406
Read file
FileRead, Temp1, *m100 %A_ScriptFullPath%
0.171265
Read file line
FileReadLine, Temp1, %A_ScriptFullPath%, 2
0.145268
Append to file
FileAppend, c, %A_Temp%\Temp.txt
0.647552
Copy file
FileCopy, %A_Temp%\Temp.txt, %A_Temp%\Temp1.txt, 1
1.753150
Move file
FileMove, %A_Temp%\Temp.txt, %A_Temp%\Temp.txt, 1
1.477209
Filesystem loop
Loop, %A_ScriptFullPath%
 Return
0.140000
File reading loop
Loop, Read, %A_ScriptFullPath%
 Return
0.144209

5,000 iterations each

Control Flow

BenchmarkCodeAverage time per run (ms)
Normal loop
Loop, 1
{
 
}
0.011507
While loop
While, (A_Index = 1)
{
 
}
0.010628
Parsing loop
Loop, Parse, Variable, ,
{
 
}
0.011914
Blank subroutine call
Gosub, BlankLabel
0.011195
Blank function call
BlankFunction()
0.011730

1,000,000 iterations each

Environment Variables

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

500,000 iterations each

Keyboard and mouse

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

5,000 iterations each

Dynamic Variables

BenchmarkCodeAverage time per run (ms)
Dynamic variable access
% %Variable%
0.013891
Dynamic variable assignment
%Variable% = abcdeg
0.014895

1,000,000 iterations each

System Information

FieldValue
AutoHotkey VersionAutoHotkey v1.0.96.00 ANSI (x86)
OS NameMicrosoft Windows 7 Enterprise
OS Version6.1.7601 Service Pack 1 Build 7601
OS ConfigurationStandalone Workstation
OS Build TypeMultiprocessor Free
System ManufacturerDell Inc.
System ModelLatitude D620
System TypeX86-based PC
Processor(s)1 Processor(s) Installed.,[01]: x86 Family 6 Model 14 Stepping 8 GenuineIntel ~989 Mhz
BIOS VersionDell Inc. A04, 8/28/2006
Total Physical Memory3,062 MB
Available Physical Memory1,434 MB
Virtual Memory: Max Size6,123 MB
Virtual Memory: Available4,232 MB