[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
concatenate and merge
- Subject: concatenate and merge
- From: firstname.lastname@example.org (Mathieu Lafourcade)
- Date: Tue, 6 Jul 1993 16:22:37 +0200
I have wrote a transducer in MCL and it try to optimize it. I found that
the merge function conses much less that concatenate (1/3). On the other
hand it is a bit slower (4/3).
I wrote the following code :
(dotimes (i 10000)
(merge 'string "abcdef" "hello" #'(lambda (y x) (declare (ignore x)) y)))
(time (dotimes (i 10000) (concatenate 'string "hello" "abcdef")))
which gives :
(DOTIMES (I 10000) (MERGE 'STRING "abcdef" "hello" #'(LAMBDA (Y X) (DECLARE
(IGNORE X)) Y))) took 3173 milliseconds (3.173 seconds) to run.
Of that, 61 milliseconds (0.061 seconds) were spent in The Cooperative
240000 bytes of memory allocated.
(DOTIMES (I 10000) (CONCATENATE 'STRING "hello" "abcdef")) took 2153
milliseconds (2.153 seconds) to run.
Of that, 26 milliseconds (0.026 seconds) were spent in The Cooperative
322 milliseconds (0.322 seconds) was spent in GC.
720000 bytes of memory allocated.
Beside these considerations, I have one question : does it exist a better
function than merge or concatenate (both in space and time) ? Typically I
am doing the following struff a lot of time:
(method do-it ((self c) (s string))
(setf (output-s self) (concatenate 'string (output-s self) s)))
GETA (Groupe d'Etude pour la Traduction Automatique)
IMAG (Institut de Mathematiques Appliquees de Grenoble)
BP 53 38041 GRENOBLE CEDEX 9, FRANCE
Tel : (33) 76 51 43 80 Fax : (33) 76 51 44 05