time(1) コマンドや、Common Lisp の time 関数 のような、 処理全体にどのくらい時間がかかっているのか教えてくれる関数が Standard ML の標準ライブラリになさそうだった。なので自分でいい加減なものを書いてみた。
幸い、実行時間を測るタイマ自体は標準ライブラリが提供してくれていた。
(flycheck-define-checker mlton | |
"Standard ML type and syntax checking with mlton compiler. | |
See URL 'http://mlton.org" | |
:command ("mlton" "-stop" "tc" source) | |
:error-patterns | |
((error line-start "Error: " (file-name) blank line ?\. column ?\. "\n" | |
(message (1+ line-start (1+ blank) (+ nonl) "\n")))) | |
:mode (sml-mode)) |
(defun tarai (x y z) | |
(declare (optimize (speed 3) (safety 0))) | |
(if (<= x y) | |
y | |
(tarai (tarai (1- x) y z) | |
(tarai (1- y) z x) | |
(tarai (1- z) x y)))) | |
(compile 'tarai) | |
(print (tarai 12 6 0)) |