スクリプトのパフォーマンス

提供: AutoHotkey Wiki
移動: 案内検索
リファレンス > その他解説 > スクリプトのパフォーマンス

スクリプトのパフォーマンスを最大にするには、SetFormatを利用せず(Fastモードを除く)に、以下の行をスクリプトの先頭に記述する。

#NoEnv
SetBatchLines, -1
ListLines, Off

上記に加えて以下のコマンドを併用すればパフォーマンスを上げることが可能(スクリプト書き方にもよる)。

SendMode, SetKeyDelay, SetMouseDelay, SetWinDelay, SetControlDelay, SetDefaultMouseSpeed

組み込みのパフォーマンス調整機能[編集]

どのスクリプトもロード時の構文チェックの際にセミコンパイルされた状態になる。 これによりメモリ消費量を抑え、実行性能を上げることが可能となっている。

以下に最適化の過程(セミコンパイル)に関する技術的な詳細を挙げる。

  • Input and output variables (when their names don't contain references to other variables) and group names are resolved to memory addresses.
  • Loops, blocks, IFs, and ELSEs are given the memory addresses of their related jump-points in the script.
  • The destination of each Hotkey, Gosub, and Goto is resolved to a memory address unless it is a variable.
  • Each command name is replaced by an address in a jump table.
  • Each line is pre-parsed into a list of parameters, and each parameter is pre-parsed into a list of variables (if any).
  • Each expression is tokenized and converted from infix to postfix.
  • Each reference to a variable or function is resolved to a memory address.
  • Literal integers in expressions and math/comparison commands are replaced with binary integers.

上記に加え、スクリプト実行中に数値をバイナリ形式でキャッシュし、文字列との相互変換をなるべく避けるようにして高速化を図ることもできる。この件に関しては、SetFormat に詳細がある