[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Best way to convert inte
- To: "Peter Stone" <uunet!xs4all.nl!psto@uunet.UU.NET>
- Subject: Re: Best way to convert inte
- From: "Don Mitchell" <proact!dhm@uunet.UU.NET>
- Date: 16 Feb 1995 14:10:56 -0600
- Cc: "Info-mcl" <info-mcl@digitool.com>
- Sender: owner-info-mcl@digitool.com
Subject: RE>Best way to convert integer to st
Wow, 96 bytes per string. Each time you execute this you're creating a new
string; so, the obvious alternative is to reuse the string. You could create a
string w/ a fill-pointer and pass that to format. (This suggestion assumes that
you need the string or find it convenient to have it.)
(defun test (n string)
(setf (fill-pointer string) 0)
(format string "~D" n))
(time (let ((string (make-array 4 :element-type 'character :fill-pointer 0)))
(dotimes (i 1000) (test 123 string))))
(LET ((STRING (MAKE-ARRAY 4 :ELEMENT-TYPE 'CHARACTER :FILL-POINTER 0))) (DOTIMES
(I 1000) (TEST 123 STRING))) took 364 milliseconds (0.364 seconds) to run.
Of that, 45 milliseconds (0.045 seconds) were spent in The Cooperative
Multitasking Experience.
48 bytes of memory allocated.
--------------------------------------
Date: 2/15/95 7:11 AM
To: Don Mitchell
From: Peter Stone
...
(time (dotimes (i 1000) (princ-to-string 123)))
...
---------------------
Donald H. Mitchell Domain: dhm@pro-solution.com
Proactive Solutions Inc. UUCP: uunet!proact!dhm
5314 S. Yale Ave., Suite 402 Voice: 918.497.2330
Tulsa, OK 74135 FAX: 918.497.2323