[plt-scheme] Strange benchmark for string=?
> (let ((s1 (make-string 50000 #\a))
(s2 (make-string 50000 #\a)))
(time (do ((i 0 (+ i 1)))
((= i 10000))
(string=? s1 s2))))
cpu time: 1902 real time: 2133 gc time: 0
> (let ((s1 (make-string 50000 #\a))
(s2 (make-string 50001 #\a)))
(time (do ((i 0 (+ i 1)))
((= i 10000))
(string=? s1 s2))))
cpu time: 1943 real time: 2604 gc time: 0
> (let ((s1 (make-string 50000 #\a))
(s2 (make-string 50000 #\a)))
(define (my-string=? s1 s2)
(and (= (string-length s1)
(string-length s2))
(string=? s1 s2)))
(time (do ((i 0 (+ i 1)))
((= i 10000))
(my-string=? s1 s2))))
cpu time: 1883 real time: 2012 gc time: 0
> (let ((s1 (make-string 50000 #\a))
(s2 (make-string 50001 #\a)))
(define (my-string=? s1 s2)
(and (= (string-length s1)
(string-length s2))
(string=? s1 s2)))
(time (do ((i 0 (+ i 1)))
((= i 10000))
(my-string=? s1 s2))))
cpu time: 40 real time: 90 gc time: 0
Is this the fault of unicode or just an oversight
in string=? ?
--
Jens Axel Søgaard