match-bind оказался макросом, раскрывающимся в макрос, компилирующий
регексп и замыкающий тело относительно скомпиленного результата. Так что
я решил сделать пообъективнее бенч и вот результаты:
(defpackage :ppcre-vs-irregsexp
(:use :cl
:cl-ppcre
:cl-irregsexp))
(in-package :ppcre-vs-irregsexp)(defvar *ppcre-scanner* (create-scanner "a+(\\S+)b"))(time
(dotimes (_
100000000)
(scan-to-strings
*ppcre-scanner* "xaaaa77bd")))
Evaluation took:
393.167 seconds of real time
392.810517 seconds of total run time
(391.780911 user, 1.029606 system)
[ Run times consist of 4.622 seconds GC time, and 388.189 seconds
non-GC time. ]
99.91% CPU
836,615,161,054 processor cycles
28,000,274,192 bytes consed
(time
(dotimes (_
100000000)
(match-bind
(_ (+ "a")
result "b")
"xaaaa77bd"
result)))
Evaluation took:
50.606 seconds of real time
50.606724 seconds of total run time
(50.372723 user, 0.234001 system)
[ Run times consist of 1.656 seconds GC time, and 48.951 seconds
non-GC time. ]
100.00% CPU
107,671,584,766 processor cycles
9,600,109,512 bytes consed
Так что здесь выгода от on-fly
вполне неиллюзорна. Кроме того, этот cl-
irregsexp выглядит очень прототипно - мне
кажется, там можно еще много соптимизировать.