(defparameter *mj-timer-total* 0) (defun mj-timer (vm) "Update the timer" (incf *mj-timer-total* (case (car (vm-state-inst vm)) ((jump jumpz jumpn jumpi) 2) ((call calli return) 2) (debug 0) (break 0) (t 1)))) (defun time-java-asm (name &optional (stdout t) (stdin nil)) "Time the MJ bytecode" (let ((vm (load-java-asm name))) (setf *mj-timer-total* 0) (setf (vm-state-stdout vm) stdout) (setf (vm-state-stdin vm) stdin) (setf (vm-state-debug-hook vm) #'mj-timer) (run-vm vm) *mj-timer-total*))