Mercurial > core / lisp/lib/rt/bench.lisp
changeset 698: |
96958d3eb5b0 |
parent: |
0f0e5f9b5c55
|
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Fri, 04 Oct 2024 22:04:59 -0400 |
permissions: |
-rw-r--r-- |
description: |
fixes |
1 ;;; lib/rt/bench.lisp --- Benchmarking Framework 3 ;; This package provides an interface for benchmarking Lisp code. 8 (defvar *bench-count* 10 "Default number of iterations to repeat a bench test for. This value is 9 used when the slot value of :BENCH is t.") 11 (defmacro bench (iter &body body) 12 `(loop for i from 1 to ,iter 15 (defmethod do-bench ((self test) &optional fx) 16 (declare (ignorable fx)) 19 (if-let ((opt *compile-tests*)) 21 (when (eq opt t) (setq opt *test-opts*)) 22 ;; TODO 2023-09-21: handle failures here 23 (let ((fn (compile-test self :declare opt))) 24 (bench *bench-count* (funcall fn))) 25 (setf %test-result (make-test-result :pass (test-fn self)))) 27 (bench *bench-count* (eval-test self)) 28 (setf %test-result (make-test-result :pass (test-name self))))))) 29 (if *catch-test-errors* 31 ((style-warning #'muffle-warning) 35 (setf %test-result (make-test-result :fail c)) 36 (return-from %test-bail %test-result)))) 40 (defclass benchmark (test-object) ()) 42 (defmacro defbench (name props &body body) 43 "Define a BENCHMARK with NAME modulo PROPS with a benchmark-form of BODY. 45 PROPS is a plist which accepts the following keywords: