;; this file: ;; https://dataswamp.org/~incal/cl/bench/timing.cl ;; ;; code from: ;; https://cl-cookbook.sourceforge.net/dates_and_times.html ;; https://drmeister.wordpress.com/2015/07/30/timing-data-comparing-cclasp-to-c-sbcl-and-python/ (defmacro timing (&body forms) (let ((real1 (gensym)) (real2 (gensym)) (run1 (gensym)) (run2 (gensym)) (res (gensym))) `(let*((,real1 (get-internal-real-time)) (,run1 (get-internal-run-time)) (,res (progn ,@forms)) (,run2 (get-internal-run-time)) (,real2 (get-internal-real-time))) (format *debug-io* ";; ~f s real time~%" (/ (- ,real2 ,real1) internal-time-units-per-second)) (format t ";; ~f s run time~%" (/ (- ,run2 ,run1) internal-time-units-per-second)) ,res)))