[cl-ppcre-devel] scan's performance

Edi Weitz edi at agharta.de
Thu Dec 28 16:52:18 UTC 2006


On Thu, 28 Dec 2006 21:14:53 +1000, Igor Plekhov <penguin at ocean.vvo.ru> wrote:

> It is on sbcl-0.9.16 under Linux.
>
> WILD> (time (scan (list :sequence :everything "abc")
>                   "foobar"))
> Evaluation took:
>   0.017 seconds of real time
>   0.006998 seconds of user run time
>   0.0 seconds of system run time
>   1 page fault and
>   4,456,456 bytes consed.
> NIL
>
> WILD> (time (scan (list :sequence :everything "abc" :everything)
>                   "foobar"))
> Evaluation took:
>   0.0 seconds of real time
>   0.0 seconds of user run time
>   0.0 seconds of system run time
>   0 page faults and
>   0 bytes consed.
> NIL
>
> Why so great difference?

Because for the first expression CL-PPCRE realizes that it can add a
special test for the constant string "abc" at the end.  For the
second, it can't.

> There must be two :everything around something to the trick to work.
>
> PS.  Yes, I need a scan pattern generated at run time.  With a
> static pattern it works incredibly fast, as usual.

Bind *USE-BMH-MATCHERS* to NIL and you should be set.

  * (let ((*use-bmh-matchers* nil))
      (time (scan (list :sequence :everything "abc") "foobar")))

  Evaluation took:
    0.0 seconds of real time
    0.0 seconds of user run time
    0.0 seconds of system run time
    0 calls to %EVAL
    0 page faults and
    0 bytes consed.
  NIL

Cheers,
Edi.



More information about the Cl-ppcre-devel mailing list