[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Compiling DOTIMES
While using code to generate possibilities, Tack Fu of GTE noted that
compiling nested DOTIMESs took considerably more time that compiling
"equivalent" LOOPs. We've tried a few depths of nesting; it quickly
gets out of hand.
Consider the simple lambda form
(lambda (&aux (counter 0))
(dotimes (a 3)
(ignore a)
(dotimes (b 3)
(ignore b)
(dotimes (c 3)
(ignore c)
(dotimes (x 3)
(ignore x)
(dotimes (y 3)
(ignore y)
(dotimes (z 3)
(ignore z)
(incf counter)))))))
counter)
It takes 40 seconds to compile this on a 3640.
On the other hand, compiling
(lambda (&aux (counter 0))
(loop for a from 0 below 3 do
(ignore a)
(loop for b from 0 below 3 do
(ignore b)
(loop for c from 0 below 3 do
(ignore c)
(loop for x from 0 below 3 do
(ignore x)
(loop for y from 0 below 3 do
(ignore y)
(loop for z from 0 below 3 do
(ignore z)
(incf counter)))))))
counter)
never takes more than 1.1 second. To further confound matters, the
function compiled from DOTIMES is about 20% faster than the function
based on LOOP.
It would seem that with DOTIMES being more r