Really?
#||
(ql:quickload "com.informatimago.common-lisp.cesarum")
||#
(declaim (optimize (speed 3) (safety 1)))
(defun concatenate-strings/mine (strings)
(with-output-to-string (s)
(loop for string in strings
do (write-string string s))))
(defun concatenate-strings/pjb (strings)
(com.informatimago.common-lisp.cesarum.string:concatenate-strings strings))
(defparameter *strings*
(make-list 100000 :initial-element "foo"))
#||
(time (progn
(concatenate-strings/mine *strings*)
(values)))
(time (progn
(concatenate-strings/pjb *strings*)
(values)))
||#
Evaluation took:
0.010 seconds of real time
0.009297 seconds of total run time (0.008350 user, 0.000947 system)
90.00% CPU
21,449,980 processor cycles
3,150,912 bytes consed
; No value
Evaluation took:
0.015 seconds of real time
0.014656 seconds of total run time (0.013433 user, 0.001223 system)
100.00% CPU
33,808,210 processor cycles
2,805,664 bytes consed
; No value
Looks like the string-stream version is 33% faster than yours :-)
This was using SBCL 1.3.2.114; using Clozure Common Lisp 1.12-dev-r16752
I get 0.015067s and 0.020489s, respectively.
If I increase the number of strings to 10M, concatenate-strings/mine is
more than twice as fast (0.799s versus 1.625s).
Note: after looking at your code, I actually expected it to be faster
than using with-output-to-string.