Here's what I ran:
Code: Select all
(defparameter *cycle* 0)
(defun test-arg (num cycle)
(rem cycle (1+ num)))
(defun test-dyn (num)
(rem *cycle* (1+ num)))
(defun measure ()
(time
(let ((cycle 0)
(acc 0))
(dotimes (n 100000000)
(Incf acc (test-arg n cycle))
(incf cycle 7))))
(time
(let ((acc 0))
(dotimes (n 100000000)
(incf acc (test-dyn n))
(incf *cycle* 7))))
(time
(let ((acc 0)
(*cycle* 0))
(dotimes (n 100000000)
(Incf acc (test-dyn n))
(incf *cycle* 7)))))
Comments on methodology welcome!
Seems the results won't fit, so I'll post in a reply...