From f6799959f40b3d376479da75797d95f8943afc57 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Wed, 15 May 2013 09:37:02 +0100 Subject: [PATCH] TIME macro --- src/misc.lisp | 9 +++++++++ src/toplevel.lisp | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/misc.lisp b/src/misc.lisp index b1958b3..b3b24c1 100644 --- a/src/misc.lisp +++ b/src/misc.lisp @@ -17,3 +17,12 @@ (defun lisp-implementation-type () "JSCL") + +(defmacro time (form) + (let ((start (gensym)) + (end (gensym))) + `(let ((,start (get-internal-real-time)) + (,end)) + (prog1 (progn ,form) + (setq ,end (get-internal-real-time)) + (format t "Execution took ~a seconds.~%" (/ (- ,end ,start) 1000.0)))))) diff --git a/src/toplevel.lisp b/src/toplevel.lisp index 0bd763f..d148a47 100644 --- a/src/toplevel.lisp +++ b/src/toplevel.lisp @@ -75,7 +75,7 @@ second set setf setq seventh sixth some string string-upcase string= stringp sublis subseq subst symbol-function symbol-name symbol-package symbol-plist symbol-value symbolp t tagbody tailp tenth third throw - tree-equal truncate unless unwind-protect values values-list variable + time tree-equal truncate unless unwind-protect values values-list variable vector-push-extend warn when write-line write-string zerop)) (setq *package* *user-package*) -- 1.7.10.4