(in-package :performance-test) (defun function-duration (func) "Hooks into specified function and provides the duration in *STANDARD-OUTPUT*" (let* ( (pck (symbol-package func)) (pck-name (package-name pck)) ;; The following line is just for testing. ;; Original and new function will be buffered to restore/unhook later. (new-func (string-upcase (format nil "~a-~a" func (oli:sd-gen-unique-filename ""))))) (when new-func (eval `(defun ,(intern new-func pck-name) (&rest args) (if args (let ( (start-time (frame2:seconds-since-1970)) (ret-val (apply ,(symbol-function func) args))) ;; Error: Uncompiled functions does not seem to work at symbol-function. (format t "~%Duration: ~a" (- (frame2:seconds-since-1970) start-time)) ret-val) (let ( (start-time (frame2:seconds-since-1970)) (ret-val (funcall ,(symbol-function func)))) ;; Error: Uncompiled functions does not seem to work at symbol-function. (format t "~%Duration: ~a" (- (frame2:seconds-since-1970) start-time)) ret-val)))) (setf (symbol-function func) (symbol-function (read-from-string (format nil "~a::~a" pck-name new-func))))))) (defun test-func (cnt) "Just another function to test." (dotimes (i cnt) (format t "~%~a" i))) ;; This one works... (onyl on first run, but that is okay). ;; (function-duration 'oli:sd-inq-obj-children) ;; (oli:sd-inq-obj-children (oli:sd-pathname-to-obj "/")) ;; This one fails... (function-duration 'performance-test::test-func) (test-func 20) ;; Error: LISP-Fehler: ;; The function LAMBDA-BLOCK is undefined. ;; Signalled by LET ;; Broken at LET. Type :H for Help. ;; Backtrace: eval > agent:preselect > frame2:get-action-pm > load > test-func-3on2sa541i57hq610896 > if > LET