| 1 | ;; Driver for Eric Marsden's CL-BENCH Lisp performance benchmarks. |
|---|
| 2 | |
|---|
| 3 | (in-package :cl-user) |
|---|
| 4 | |
|---|
| 5 | #+armedbear |
|---|
| 6 | (require 'pprint) |
|---|
| 7 | |
|---|
| 8 | #+allegro |
|---|
| 9 | (progn |
|---|
| 10 | (setq excl:*record-source-file-info* nil) |
|---|
| 11 | (setq excl:*load-source-file-info* nil) |
|---|
| 12 | (setq excl:*record-xref-info* nil) |
|---|
| 13 | (setq excl:*load-xref-info* nil)) |
|---|
| 14 | |
|---|
| 15 | (setf *default-pathname-defaults* #p"/home/peter/cl-bench/") |
|---|
| 16 | |
|---|
| 17 | (load #p"defpackage.lisp") |
|---|
| 18 | (compile-file #p"files/arrays.olisp") |
|---|
| 19 | (compile-file #p"files/bignum.olisp") |
|---|
| 20 | (compile-file #p"files/boehm-gc.olisp") |
|---|
| 21 | (compile-file #p"files/clos.olisp") |
|---|
| 22 | (compile-file #p"files/crc40.olisp") |
|---|
| 23 | (compile-file #p"files/deflate.olisp") |
|---|
| 24 | (compile-file #p"files/gabriel.olisp") |
|---|
| 25 | (compile-file #p"files/hash.olisp") |
|---|
| 26 | (compile-file #p"files/math.olisp") |
|---|
| 27 | (compile-file #p"files/ratios.olisp") |
|---|
| 28 | (compile-file #p"files/richards.olisp") |
|---|
| 29 | (compile-file #p"files/misc.olisp") |
|---|
| 30 | |
|---|
| 31 | (load (compile-file-pathname #p"files/arrays.olisp")) |
|---|
| 32 | (load (compile-file-pathname #p"files/bignum.olisp")) |
|---|
| 33 | (load (compile-file-pathname #p"files/boehm-gc.olisp")) |
|---|
| 34 | (load (compile-file-pathname #p"files/clos.olisp")) |
|---|
| 35 | (load (compile-file-pathname #p"files/crc40.olisp")) |
|---|
| 36 | (load (compile-file-pathname #p"files/deflate.olisp")) |
|---|
| 37 | (load (compile-file-pathname #p"files/gabriel.olisp")) |
|---|
| 38 | (load (compile-file-pathname #p"files/hash.olisp")) |
|---|
| 39 | (load (compile-file-pathname #p"files/math.olisp")) |
|---|
| 40 | (load (compile-file-pathname #p"files/ratios.olisp")) |
|---|
| 41 | (load (compile-file-pathname #p"files/richards.olisp")) |
|---|
| 42 | (load (compile-file-pathname #p"files/misc.olisp")) |
|---|
| 43 | (compile-file #p"support.lisp") |
|---|
| 44 | (load (compile-file-pathname #p"support.lisp")) |
|---|
| 45 | |
|---|
| 46 | (in-package :cl-bench) |
|---|
| 47 | |
|---|
| 48 | (export '(run-benchmark run-benchmarks)) |
|---|
| 49 | |
|---|
| 50 | (setf *benchmark-output* t) |
|---|
| 51 | |
|---|
| 52 | #+(or armedbear clisp) |
|---|
| 53 | (defun bench-gc () |
|---|
| 54 | (ext:gc)) |
|---|
| 55 | |
|---|
| 56 | #+sbcl |
|---|
| 57 | (defun bench-gc () |
|---|
| 58 | (sb-ext:gc #+gencgc :full #+gencgc t)) |
|---|
| 59 | |
|---|
| 60 | #+allegro |
|---|
| 61 | (defun bench-gc () |
|---|
| 62 | (excl:gc)) |
|---|
| 63 | |
|---|
| 64 | (defun report-filename () |
|---|
| 65 | (let ((impl "")) |
|---|
| 66 | #+allegro (setf impl "-allegro") |
|---|
| 67 | #+armedbear (setf impl "-armedbear") |
|---|
| 68 | #+clisp (setf impl "-clisp") |
|---|
| 69 | #+sbcl (setf impl "-sbcl") |
|---|
| 70 | (multiple-value-bind (sec min hour day month year) |
|---|
| 71 | (get-decoded-time) |
|---|
| 72 | (format nil "~abenchmark-~d~2,'0d~2,'0dT~2,'0d~2,'0d~a" |
|---|
| 73 | #+win32 "" #-win32 "/var/tmp/" |
|---|
| 74 | year month day hour min impl)))) |
|---|
| 75 | |
|---|
| 76 | (defun run-benchmark (function &optional args (times 1)) |
|---|
| 77 | (let ((name (symbol-name function))) |
|---|
| 78 | (format t "Running benchmark ~A" (symbol-name function)) |
|---|
| 79 | (when (> times 1) |
|---|
| 80 | (format t " (~D runs)" times)) |
|---|
| 81 | (terpri) |
|---|
| 82 | (force-output) |
|---|
| 83 | (let (before-real after-real before-user after-user) |
|---|
| 84 | (setf before-real (get-internal-real-time)) |
|---|
| 85 | (setf before-user (get-internal-run-time)) |
|---|
| 86 | (dotimes (i times) |
|---|
| 87 | (apply function args)) |
|---|
| 88 | (setf after-user (get-internal-run-time)) |
|---|
| 89 | (setf after-real (get-internal-real-time)) |
|---|
| 90 | (let ((real (/ (- after-real before-real) internal-time-units-per-second)) |
|---|
| 91 | (user (/ (- after-user before-user) internal-time-units-per-second))) |
|---|
| 92 | (format *benchmark-output* |
|---|
| 93 | ";; ~25a ~8,2f ~8,2f~%" |
|---|
| 94 | name real user) |
|---|
| 95 | (format *trace-output* |
|---|
| 96 | ";; ~25a ~8,2f ~8,2f~%" |
|---|
| 97 | name real user)) |
|---|
| 98 | (force-output *benchmark-output*))) |
|---|
| 99 | (bench-gc) |
|---|
| 100 | (values)) |
|---|
| 101 | |
|---|
| 102 | (defun run-benchmarks () |
|---|
| 103 | (with-open-file (f (report-filename) |
|---|
| 104 | :direction :output |
|---|
| 105 | :if-exists :supersede) |
|---|
| 106 | (let ((*benchmark-output* f)) |
|---|
| 107 | (format *benchmark-output* "~A ~A " |
|---|
| 108 | (lisp-implementation-type) (lisp-implementation-version)) |
|---|
| 109 | (multiple-value-bind (second minute hour date month year) |
|---|
| 110 | (get-decoded-time) |
|---|
| 111 | (format *benchmark-output* "~d-~2,'0d-~2,'0d ~2,'0d:~2,'0d~%" |
|---|
| 112 | year month date hour minute)) |
|---|
| 113 | (format *benchmark-output* "~a~%" (short-site-name)) |
|---|
| 114 | (force-output *benchmark-output*) |
|---|
| 115 | (bench-gc) |
|---|
| 116 | ;; The benchmarks. |
|---|
| 117 | #+nil |
|---|
| 118 | (run-benchmark 'cl-bench.misc:run-compiler nil 3) |
|---|
| 119 | #+nil |
|---|
| 120 | (run-benchmark 'cl-bench.misc:run-fasload nil 20) |
|---|
| 121 | #-allegro |
|---|
| 122 | (run-benchmark 'cl-bench.misc:run-permutations nil 2) |
|---|
| 123 | #+nil |
|---|
| 124 | (progn |
|---|
| 125 | (cl-bench.misc::setup-walk-list/seq) |
|---|
| 126 | (run-benchmark 'cl-bench.misc:walk-list/seq) |
|---|
| 127 | (setf cl-bench.misc::*big-seq-list* nil) |
|---|
| 128 | (bench-gc)) |
|---|
| 129 | #+nil |
|---|
| 130 | (progn |
|---|
| 131 | (cl-bench.misc::setup-walk-list/mess) |
|---|
| 132 | (run-benchmark 'cl-bench.misc:walk-list/mess) |
|---|
| 133 | (setf cl-bench.misc::*big-mess-list* nil) |
|---|
| 134 | (bench-gc)) |
|---|
| 135 | (run-benchmark 'cl-bench.gabriel:boyer nil 30) |
|---|
| 136 | (run-benchmark 'cl-bench.gabriel:browse nil 10) |
|---|
| 137 | (run-benchmark 'cl-bench.gabriel:dderiv-run nil 50) |
|---|
| 138 | (run-benchmark 'cl-bench.gabriel:deriv-run nil 60) |
|---|
| 139 | (run-benchmark 'cl-bench.gabriel:run-destructive nil 100) |
|---|
| 140 | (run-benchmark 'cl-bench.gabriel:run-div2-test1 nil 200) |
|---|
| 141 | (run-benchmark 'cl-bench.gabriel:run-div2-test2 nil 200) |
|---|
| 142 | (run-benchmark 'cl-bench.gabriel:run-fft nil 30) |
|---|
| 143 | (run-benchmark 'cl-bench.gabriel:run-frpoly/fixnum nil 100) |
|---|
| 144 | (run-benchmark 'cl-bench.gabriel:run-frpoly/bignum nil 30) |
|---|
| 145 | (run-benchmark 'cl-bench.gabriel:run-frpoly/float nil 100) |
|---|
| 146 | (run-benchmark 'cl-bench.gabriel:run-puzzle nil 1500) |
|---|
| 147 | (run-benchmark 'cl-bench.gabriel:run-tak) |
|---|
| 148 | (run-benchmark 'cl-bench.gabriel:run-ctak) |
|---|
| 149 | (run-benchmark 'cl-bench.gabriel:run-trtak) |
|---|
| 150 | (run-benchmark 'cl-bench.gabriel:run-takl) |
|---|
| 151 | #+nil |
|---|
| 152 | (run-benchmark 'cl-bench.gabriel:run-stak) |
|---|
| 153 | (run-benchmark 'cl-bench.gabriel:fprint/ugly nil 200) |
|---|
| 154 | (run-benchmark 'cl-bench.gabriel:fprint/pretty) |
|---|
| 155 | (run-benchmark 'cl-bench.gabriel:run-traverse) |
|---|
| 156 | (run-benchmark 'cl-bench.gabriel:run-triangle) |
|---|
| 157 | (run-benchmark 'cl-bench.richards:richards) |
|---|
| 158 | (run-benchmark 'cl-bench.math:run-factorial nil 1000) |
|---|
| 159 | (run-benchmark 'cl-bench.math:run-fib nil 50) |
|---|
| 160 | (run-benchmark 'cl-bench.math:run-fib-ratio) |
|---|
| 161 | #+nil |
|---|
| 162 | (run-benchmark 'cl-bench.math:run-ackermann) |
|---|
| 163 | (run-benchmark 'cl-bench.math:run-mandelbrot/complex) |
|---|
| 164 | (run-benchmark 'cl-bench.math:run-mandelbrot/dfloat) |
|---|
| 165 | (run-benchmark 'cl-bench.math:run-mrg32k3a) |
|---|
| 166 | (run-benchmark 'cl-bench.crc:run-crc40) |
|---|
| 167 | (run-benchmark 'cl-bench.bignum:run-elem-100-1000) |
|---|
| 168 | (run-benchmark 'cl-bench.bignum:run-elem-1000-100) |
|---|
| 169 | (run-benchmark 'cl-bench.bignum:run-elem-10000-1) |
|---|
| 170 | (run-benchmark 'cl-bench.bignum:run-pari-100-10) |
|---|
| 171 | (run-benchmark 'cl-bench.bignum:run-pari-200-5) |
|---|
| 172 | (run-benchmark 'cl-bench.bignum:run-pi-decimal/small) |
|---|
| 173 | #-allegro |
|---|
| 174 | (run-benchmark 'cl-bench.bignum:run-pi-decimal/big) |
|---|
| 175 | (run-benchmark 'cl-bench.bignum:run-pi-atan) |
|---|
| 176 | (run-benchmark 'cl-bench.ratios:run-pi-ratios) |
|---|
| 177 | #-clisp |
|---|
| 178 | (run-benchmark 'cl-bench.hash:run-slurp-lines nil 30) |
|---|
| 179 | #-allegro |
|---|
| 180 | (run-benchmark 'cl-bench.hash:hash-strings nil 2) |
|---|
| 181 | (run-benchmark 'cl-bench.hash:hash-integers nil 10) |
|---|
| 182 | #-allegro |
|---|
| 183 | (run-benchmark 'cl-bench.boehm-gc:gc-benchmark) |
|---|
| 184 | (run-benchmark 'cl-bench.deflate:run-deflate-file nil 100) |
|---|
| 185 | #-allegro |
|---|
| 186 | (run-benchmark 'cl-bench.arrays:bench-1d-arrays) |
|---|
| 187 | #-allegro |
|---|
| 188 | (run-benchmark 'cl-bench.arrays:bench-2d-arrays '(1000 1)) |
|---|
| 189 | #-allegro |
|---|
| 190 | (run-benchmark 'cl-bench.arrays:bench-3d-arrays '(100 1)) |
|---|
| 191 | (run-benchmark 'cl-bench.arrays:bench-bitvectors nil 3) |
|---|
| 192 | #-allegro |
|---|
| 193 | (run-benchmark 'cl-bench.arrays:bench-strings) |
|---|
| 194 | #-allegro |
|---|
| 195 | (run-benchmark 'cl-bench.arrays:bench-strings/adjustable '(1000000 1)) |
|---|
| 196 | #-(or allegro clisp) |
|---|
| 197 | (run-benchmark 'cl-bench.arrays:bench-string-concat '(1000000 1)) |
|---|
| 198 | #-allegro |
|---|
| 199 | (run-benchmark 'cl-bench.arrays:bench-search-sequence '(1000000 1)) |
|---|
| 200 | (return-from run-benchmarks) |
|---|
| 201 | (run-benchmark 'cl-bench.clos:run-defclass) |
|---|
| 202 | (run-benchmark 'cl-bench.clos:run-defmethod) |
|---|
| 203 | (run-benchmark 'cl-bench.clos:make-instances) |
|---|
| 204 | (run-benchmark 'cl-bench.clos:make-instances/simple) |
|---|
| 205 | (run-benchmark 'cl-bench.clos:methodcalls/simple) |
|---|
| 206 | (run-benchmark 'cl-bench.clos:methodcalls/simple+after) |
|---|
| 207 | #-clisp |
|---|
| 208 | (run-benchmark 'cl-bench.clos:methodcalls/complex) |
|---|
| 209 | #+nil |
|---|
| 210 | (run-benchmark 'cl-bench.clos:run-eql-fib) |
|---|
| 211 | (run-benchmark 'cl-bench.clos::eql-fib '(16))))) |
|---|
| 212 | |
|---|
| 213 | (in-package "CL-USER") |
|---|
| 214 | |
|---|
| 215 | (import '(cl-bench:run-benchmark cl-bench:run-benchmarks)) |
|---|
| 216 | |
|---|
| 217 | (export '(run-benchmark run-benchmarks)) |
|---|