From: David Vázquez Date: Wed, 15 May 2013 08:37:02 +0000 (+0100) Subject: TIME macro X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=f6799959f40b3d376479da75797d95f8943afc57;p=jscl.git TIME macro --- 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*)