AutoHotkey Benchmarks

Contents

Control Group

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

1,000,000 iterations each

Assignment

BenchmarkCodeAverage time per run (ms)
Classic
Variable = Lorem ipsum dolor sit amet
0.001783
Classic with variable
Variable = Lorem ipsum %OtherVariable% dolor sit amet
0.002012
Expression
Variable := "Lorem ipsum dolor sit amet"
0.002820
Expression with variable
Variable := "Lorem ipsum" . OtherVariable . " dolor sit amet"
0.002759
Expression explicit concatenation
Variable := "Lorem ipsum" . " dolor sit amet"
0.003007
Expression implicit concatenation
Variable := "Lorem ipsum" " dolor sit amet"
0.003429

1,000,000 iterations each

Comparison

BenchmarkCodeAverage time per run (ms)
Classic If statement
If Variable = abcdef
 Return
0.003182
Expression If statement
If (Variable = "abcdef")
 Return
0.003196
List comparison
If Variable In abcdef
 Return
0.003580
Ternary
% (Variable = "abcdef") ? "" : ""
0.003855
Classic If between
If Variable Between 123 And 124
 Return
0.003930
Expression If between
If (Variable >= 123 && Variable <= 124)
 Return
0.004480

1,000,000 iterations each

String Searching

BenchmarkCodeAverage time per run (ms)
String search statement
IfInString, Variable, abcdef
 Return
0.004554
List search statement
If Variable Contains abcdef
 Return
0.005201
String get position command
StringGetPos, Temp1, Variable, abcdef
0.005111
In string function
InStr(Variable,"abcdef")
0.005136

1,000,000 iterations each

Regular Expressions

BenchmarkCodeAverage time per run (ms)
Match function
RegExMatch(Variable,"S)ab.*?.f$")
0.006639
Replace function
RegExReplace(Variable,"S)ab.*?.f$","$0")
0.006037
Static match
RegExMatch(Variable,"S)abcdef")
0.011973
Static replace
RegExReplace(Variable,"c","c")
0.007584

500,000 iterations each

String Manipulation

BenchmarkCodeAverage time per run (ms)
Substring function
SubStr(Variable,2,3)
0.005957
String middle command
StringMid, Temp1, Variable, 2, 3
0.007115
String trim command
StringTrimLeft, Temp1, Variable, 1
0.006506
String replace command
StringReplace, Temp1, Variable, c, c, All
0.007540

1,000,000 iterations each

String Operations

BenchmarkCodeAverage time per run (ms)
String length function
StrLen(Variable)
0.007769
String length command
StringLen, Temp1, Variable
0.006939
String split command
StringSplit, Temp, Variable, c
0.008796
Case conversion
StringUpper, Temp1, Variable
0.007644

1,000,000 iterations each

Files

BenchmarkCodeAverage time per run (ms)
File attributes and exists function
FileExist(A_ScriptFullPath)
0.117991
If file exists
IfExist, %A_ScriptFullPath%
 Return
0.110318
Get size
FileGetSize, Temp1,%A_ScriptFullPath%
0.124364
Read file
FileRead, Temp1, *m100 %A_ScriptFullPath%
0.147534
Read file line
FileReadLine, Temp1, %A_ScriptFullPath%, 2
0.143142
Append to file
FileAppend, c, %A_Temp%\Temp.txt
0.689884
Copy file
FileCopy, %A_Temp%\Temp.txt, %A_Temp%\Temp1.txt, 1
1.452774
Move file
FileMove, %A_Temp%\Temp.txt, %A_Temp%\Temp.txt, 1
1.321618
Filesystem loop
Loop, %A_ScriptFullPath%
 Return
0.130038
File reading loop
Loop, Read, %A_ScriptFullPath%
 Return
0.142128

5,000 iterations each

Control Flow

BenchmarkCodeAverage time per run (ms)
Normal loop
Loop, 1
{
 
}
0.010455
While loop
While, (A_Index = 1)
{
 
}
0.011995
Parsing loop
Loop, Parse, Variable, ,
{
 
}
0.011938
Blank subroutine call
Gosub, BlankLabel
0.011466
Blank function call
BlankFunction()
0.011598

1,000,000 iterations each

Environment Variables

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

500,000 iterations each

Keyboard and mouse

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

10,000 iterations each

Dynamic Variables

BenchmarkCodeAverage time per run (ms)
Dynamic variable access
% %Variable%
0.012646
Dynamic variable assignment
%Variable% = abcdeg
0.013031

1,000,000 iterations each

System Information

FieldValue
AutoHotkey VersionAutoHotkey v1.0.97.02 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,639 MB
Virtual Memory: Max Size6,123 MB
Virtual Memory: Available4,552 MB