AutoHotkey Benchmarks

Contents

Control Group

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

1,000,000 iterations each

Assignment

BenchmarkCodeAverage time per run (ms)
Classic
Variable = Lorem ipsum dolor sit amet
0.000983
Classic with variable
Variable = Lorem ipsum %OtherVariable% dolor sit amet
0.001126
Expression
Variable := "Lorem ipsum dolor sit amet"
0.001213
Expression with variable
Variable := "Lorem ipsum" . OtherVariable . " dolor sit amet"
0.001556
Expression explicit concatenation
Variable := "Lorem ipsum" . " dolor sit amet"
0.001434
Expression implicit concatenation
Variable := "Lorem ipsum" " dolor sit amet"
0.001491

1,000,000 iterations each

Comparison

BenchmarkCodeAverage time per run (ms)
Classic If statement
If Variable = abcdef
 Return
0.001510
Expression If statement
If (Variable = "abcdef")
 Return
0.001595
List comparison
If Variable In abcdef
 Return
0.001705
Ternary
% (Variable = "abcdef") ? "" : ""
0.001845
Classic If between
If Variable Between 123 And 124
 Return
0.001904
Expression If between
If (Variable >= 123 && Variable <= 124)
 Return
0.002227

1,000,000 iterations each

String Searching

BenchmarkCodeAverage time per run (ms)
String search statement
IfInString, Variable, abcdef
 Return
0.002219
List search statement
If Variable Contains abcdef
 Return
0.002393
String get position command
StringGetPos, Temp1, Variable, abcdef
0.002544
In string function
InStr(Variable,"abcdef")
0.002593

1,000,000 iterations each

Regular Expressions

BenchmarkCodeAverage time per run (ms)
Match function
RegExMatch(Variable,"S)ab.*?.f$")
0.002883
Replace function
RegExReplace(Variable,"S)ab.*?.f$","$0")
0.003064
Static match
RegExMatch(Variable,"S)abcdef")
0.002624
Static replace
RegExReplace(Variable,"c","c")
0.003594

500,000 iterations each

String Manipulation

BenchmarkCodeAverage time per run (ms)
Substring function
SubStr(Variable,2,3)
0.002551
String middle command
StringMid, Temp1, Variable, 2, 3
0.002966
String trim command
StringTrimLeft, Temp1, Variable, 1
0.002887
String replace command
StringReplace, Temp1, Variable, c, c, All
0.003837

1,000,000 iterations each

String Operations

BenchmarkCodeAverage time per run (ms)
String length function
StrLen(Variable)
0.002930
String length command
StringLen, Temp1, Variable
0.003042
String split command
StringSplit, Temp, Variable, c
0.004121
Case conversion
StringUpper, Temp1, Variable
0.003481

1,000,000 iterations each

Files

BenchmarkCodeAverage time per run (ms)
File attributes and exists function
FileExist(A_ScriptFullPath)
0.098674
If file exists
IfExist, %A_ScriptFullPath%
 Return
0.095710
Get size
FileGetSize, Temp1,%A_ScriptFullPath%
0.108829
Read file
FileRead, Temp1, *m100 %A_ScriptFullPath%
0.110798
Read file line
FileReadLine, Temp1, %A_ScriptFullPath%, 2
0.106387
Append to file
FileAppend, c, %A_Temp%\Temp.txt
1.285957
Copy file
FileCopy, %A_Temp%\Temp.txt, %A_Temp%\Temp1.txt, 1
4.587631
Move file
FileMove, %A_Temp%\Temp.txt, %A_Temp%\Temp.txt, 1
4.809858
Filesystem loop
Loop, %A_ScriptFullPath%
 Return
0.148427
File reading loop
Loop, Read, %A_ScriptFullPath%
 Return
0.136903

5,000 iterations each

Control Flow

BenchmarkCodeAverage time per run (ms)
Normal loop
Loop, 1
{
 
}
0.003966
While loop
While, (A_Index = 1)
{
 
}
0.005057
Parsing loop
Loop, Parse, Variable, ,
{
 
}
0.004824
Blank subroutine call
Gosub, BlankLabel
0.004828
Blank function call
BlankFunction()
0.004245

1,000,000 iterations each

Environment Variables

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

500,000 iterations each

Keyboard and mouse

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

10,000 iterations each

Dynamic Variables

BenchmarkCodeAverage time per run (ms)
Dynamic variable access
% %Variable%
0.005508
Dynamic variable assignment
%Variable% = abcdeg
0.005595

1,000,000 iterations each

System Information

FieldValue
AutoHotkey VersionAutoHotkey v1.1.10.00 Unicode (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 ~1833 Mhz
BIOS VersionDell Inc. A04, 8/28/2006
Total Physical Memory3,062 MB
Available Physical Memory1,101 MB
Virtual Memory: Max Size6,123 MB
Virtual Memory: Available3,703 MB