# HG changeset patch # User Steve Losh # Date 1471895465 0 # Node ID a1bc13ae51e7522ae67f2982df4b5fbd55627223 # Parent e21b181efc55c36e925cfafed9fd3edfff062721 Improve `timing` driver Don't calculate `since` unless we actually need it. diff -r e21b181efc55 -r a1bc13ae51e7 losh.lisp --- a/losh.lisp Mon Aug 22 19:43:24 2016 +0000 +++ b/losh.lisp Mon Aug 22 19:51:05 2016 +0000 @@ -615,17 +615,17 @@ (let ((timing-function (ecase time-type ((real-time) #'get-internal-real-time) ((run-time) #'get-internal-run-time))) - (since (or since-var (gensym)))) + (since (or since-var (when (null per-var) + iterate::*result-var*)))) (with-gensyms (start-time current-time previous-time) `(progn (with ,start-time = (funcall ,timing-function)) (for ,current-time = (funcall ,timing-function)) (for ,previous-time :previous ,current-time :initially ,start-time) - (for ,since = (- ,current-time ,start-time)) + ,(when since + `(for ,since = (- ,current-time ,start-time))) ,(when per-var - `(for ,per-var = (- ,current-time ,previous-time))) - ,(when (and (null since-var) (null per-var)) - `(finally (return ,since))))))) + `(for ,per-var = (- ,current-time ,previous-time))))))) (defmacro-driver (FOR var IN-LISTS lists)