Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!mit-eddie!uw-beaver!cornell!wilk From: wilk@fife.cs.cornell.edu (Michael Wilk) Newsgroups: comp.lang.lisp Subject: Mirror speeds Message-ID: <47064@cornell.UUCP> Date: 13 Oct 90 18:26:05 GMT Sender: nobody@cornell.UUCP Reply-To: wilk@cs.cornell.edu (Michael Wilk) Distribution: comp Organization: Cornell Univ. CS Dept, Ithaca NY Lines: 65 Here are some timing results on suggested solutions for the "mirror" function: I won't reveal the huge list I tried this on, but trust me: It was big. ------------------------------------------------------------------------------- My effort: (defun mirror (x) (if (atom x) x (let ((result nil)) (dolist (item x) (push (mirror item) result)) result))) Elapsed Real Time = 10.66 seconds Total Run Time = 10.57 seconds User Run Time = 10.55 seconds System Run Time = 0.02 seconds Process Page Faults = 131 Dynamic Bytes Consed = 0 Ephemeral Bytes Consed = 1,693,584 ------------------------------------------------------------------------------- By Eliot Handelman and Raja Sooriamurthi, modified slightly: (defun mirror (x) (if (atom x) x (append (mirror (rest x)) (list (mirror (first x)))))) Elapsed Real Time = 6.52 seconds Total Run Time = 6.43 seconds User Run Time = 6.43 seconds System Run Time = 0.00 seconds Process Page Faults = 1 Dynamic Bytes Consed = 0 Ephemeral Bytes Consed = 2,030,088 ------------------------------------------------------------------------------- By Noritake Yonezawa: (defun mirror (x) (if (atom x) x (reverse (mapcar #'mirror x)))) Elapsed Real Time = 2.62 seconds Total Run Time = 2.52 seconds User Run Time = 2.52 seconds System Run Time = 0.00 seconds Process Page Faults = 5 Dynamic Bytes Consed = 0 Ephemeral Bytes Consed = 986,984 ------------------------------------------------------------------------------- -Michael Wilk (wilk@cs.cornell.edu)