When I run the following codes in SBCL (2.3.5), I am surprised by how much bytes consed.
(defun number-of-digits (num)
(do ((n 1 (1+ n))
(num (floor num 10) (floor num 10)))
((zerop num) n)))
(defun p25 ()
(do ((a 0 (+ a b))
(b 1 a)
(n 0 (1+ n)))
((>= (number-of-digits a) 1000) n)))
(time (p25))
Evaluation took:
0.890 seconds of real time
0.888141 seconds of total run time (0.878463 user, 0.009678 system)
[ Run times consist of 0.004 seconds GC time, and 0.885 seconds non-GC time. ]
99.78% CPU
1,864,981,440 processor cycles
368,895,776 bytes consed
4782
Obviously, the codes itself does not "cons" any list. So my questions are:
Why there are so much bytes consed? Where does it come from?
How to eliminate the "consed bytes"? I mean it is just numeric calculation, I think there might be ways to make the code not to cons any byte (or just a few bytes).