(defun bpt-repeat* (n thunk) (while (/= n 0) (funcall thunk) (setq n (1- n)))) (defmacro bpt-repeat (n expr) `(bpt-repeat* ,n (lambda () ,expr))) (defun bpt-msecs (v) (let ((low (cadr v)) (microsec (caddr v))) (+ (* low 1000) (/ microsec 1000)))) (defun bpt-%time (thunk) (let ((t1 (get-internal-run-time))) (funcall thunk) (let ((t2 (get-internal-run-time))) (assert (= (car t1) (car t2))) (- (bpt-msecs t2) (bpt-msecs t1))))) (defun bpt-time* (n thunk) (insert (format "%d\n" (- (bpt-%time `(lambda () (bpt-repeat* n ,thunk))) (bpt-%time '(lambda () (bpt-repeat* n (lambda ()))))))))