;;; 7/18/2001 Alexander Repenning ;;; Micro Second Timer ;;; Fred Extension: Ctrl-x Ctrl-t will show the time is takes to compute the ;;; current form selected in a Fred buffer. Time is in micro seconds ;;; unlike a previous version of this code called hires timer, code will be executed ;;; only once. (in-package :CCL) (eval-when (:compile-toplevel :load-toplevel :execute) (defmacro TIME-TO-RUN (&body Form) " in: &body Form {t}. Measure the time is takes to run
in microseconds. Form will run only ONCE." `(locally (declare (optimize (speed 3) (safety 0))) (without-interrupts (rlet ((t1 :unsignedwide) (t2 :unsignedwide) (t3 :unsignedwide) (t4 :unsignedwide)) (#_MicroSeconds t1) ;; Cache the trap call (#_MicroSeconds t1) ,@Form (#_MicroSeconds t2) (#_WideSubtract t2 t1) ;; compensate overhead time (#_MicroSeconds t3) (#_MicroSeconds t4) (#_WideSubtract t4 t3) (- (+ (%get-unsigned-long t2 4) (* #.(expt 2 32) (%get-unsigned-long t2))) (+ (%get-unsigned-long t4 4) (* #.(expt 2 32) (%get-unsigned-long t4))))))))) (defun PRINT-TIME (Time &optional (S t)) " in: Time {float} time in seconds, &optional S {stream} default t. Print