[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] string-substitute* slow?

From: Daishi Kato
Subject: [Chicken-users] string-substitute* slow?
Date: Sat, 15 Apr 2006 08:04:38 +0900
User-agent: Wanderlust/2.15.2 (Almost Unreal) Emacs/21.4 Mule/5.0 (SAKAKI)


I was expecting that string-substitute* is
faster than calling multiple string-substitute's.

But a simple test showed me the opposite result.
Any ideas?

BTW, string-substitute* does not have the optional argument INDEX,
which string-substitute has. What's the default behavior?


(define (my-string-substitute* str smap)
  (let loop ([str str] [smap smap])
    (if (null? smap)
        (loop (string-substitute (caar smap) (cdar smap) str #f) (cdr smap)))))

#;2> (time (doit))
   3.584 seconds elapsed
     2.7 seconds in (major) GC
    3274 mutations
       1 minor GCs
     187 major GCs
#;3> (set! my-string-substitute* string-substitute*)
#;4> (time (doit))
  27.782 seconds elapsed
  15.578 seconds in (major) GC
    8220 mutations
       2 minor GCs
    1179 major GCs

reply via email to

[Prev in Thread] Current Thread [Next in Thread]