2 (in-package :clem-benchmark
)
4 (defmacro with-benchmark
(&body body
)
5 (let ((start-var (gensym))
7 `(let ((,start-var
(get-internal-run-time)))
11 (let ((,end-var
(get-internal-run-time)))
12 (coerce (/ (- ,end-var
,start-var
) internal-time-units-per-second
)
15 (defmacro benchmark-time
(benchmark-results)
16 `(nth-value 1 ,benchmark-results
))
18 (defparameter *matrix-benchmark-times
* (make-hash-table :test
'eql
))
20 (defmacro with-matrix-benchmark
((key) &body body
)
21 (let ((time-sym (gensym))
22 (results-sym (gensym)))
23 `(multiple-value-bind (,results-sym
,time-sym
)
26 (setf (gethash ,key
*matrix-benchmark-times
*)
28 (values-list ,results-sym
))))
30 (defun get-benchmark-time (key)
31 (gethash key
*matrix-benchmark-times
*))
33 (defun list-benchmarks ()
35 (maphash #'(lambda (k v
)
37 *matrix-benchmark-times
*)
40 (defun clear-benchmarks ()
41 (clrhash *matrix-benchmark-times
*))