cl-bench.lisp 15.9 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
;;;; cl-bench.lisp

(in-package #:cl-bench)

(defun bench-gc ()
  (trivial-garbage:gc :full t))

#+ (or)
(defun bench-time ()
  (error "use metering"))

12
13
14
15
16
(let ((root-dir (asdf:system-source-directory '#:cl-bench)))
  (setf (logical-pathname-translations "bench")
        `(("root;*.*"   ,root-dir)
          ("test;*.*"   ,(merge-pathnames "files/"  root-dir))
          ("result;*.*" ,(merge-pathnames "output/" root-dir)))))
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459


;;; This is disabled after the consultation with the ABCL maintainer
#+(and abcl (or))
(eval-when (:load-toplevel :execute)
  (format *debug-io* "Loading JVM compiler ...~%")
  (load "/opt/src/cvs-armedbear/j/src/org/armedbear/lisp/jvm.lisp")
  (dolist (p '("CL" "SYS" "EXT" "PRECOMPILER"))
    (jvm::jvm-compile-package p))
  (format *debug-io* "Compiling all cl-bench packages ...~%")
  (dolist (p (list-all-packages))
    (when (eql 0 (search "CL-BENCH" (package-name p)))
      (jvm::jvm-compile-package p))))


#+allegro
(progn
  (setq excl:*record-source-file-info* nil)
  (setq excl:*load-source-file-info* nil)
  (setq excl:*record-xref-info* nil)
  (setq excl:*load-xref-info* nil)
  (setq excl:*global-gc-behavior* nil))


#+clisp
(progn
  (setq custom:*warn-on-floating-point-contagion* nil))


#+clozure
(progn
  (ccl:set-lisp-heap-gc-threshold (ash 2 20)))


#+cmu
(progn
  (setq ext:*bytes-consed-between-gcs* 25000000)
  ;; to avoid problems when running the bignum code (the default of
  ;; 40000 is too low for some of the tests)
  (setq ext:*intexp-maximum-exponent* 100000))


#+corman
(progn
  (defun corman-compile-all-files ()
    (dolist (f (directory "files/*.lisp"))
      (compile-file f :print nil)))

  (defun corman-load-and-run ()
    (dolist (f (directory "files/*.fasl"))
      (load f))
    (bench-run)))


#+ecl
(progn
  (require 'cmp)
  (ext:set-limit 'ext:c-stack (* 8 1024 1024))
  #-ecl-bytecmp
  (setq c::*cc-flags* (concatenate 'string "-I. " c::*cc-flags*)))


#+lispworks
(progn
  (hcl:toggle-source-debugging nil))


#+sbcl
(progn
  (setf (sb-ext:bytes-consed-between-gcs) 25000000)
  (setq sb-ext:*intexp-maximum-exponent* 100000))

(defun naive-benchmark ()
 (load "do-compilation-script.lisp")
 (load "do-execute-script.lisp"))

#+ (or)
(defun run-benchmarks ()
  (with-open-file (f (benchmark-report-file)
                     :direction :output
                     :if-exists :supersede)
    (let ((*benchmark-output* f)
          (*print-length* nil)
          (*load-verbose* nil)
          (*compile-verbose* nil)
          (*compile-print* nil))
      (bench-report-header)

      ;; #-(or gcl armedbear)
      ;; (progn
      ;;   (format t "=== running #<benchmark COMPILER for 3 runs>~%")
      ;;   (force-output)
      ;;   (bench-gc)
      ;;   (bench-report 'cl-bench.misc:run-compiler "COMPILER" 3))

      ;; #-(or gcl armedbear)
      ;; (progn
      ;;   (format t "=== running #<benchmark LOAD-FASL for 20 runs>~%")
      ;;   (force-output)
      ;;   (bench-gc)
      ;;   (bench-report 'cl-bench.misc:run-fasload "LOAD-FASL" 20))

      #-(or lispworks-personal-edition)
      (progn
        (format t "=== running #<benchmark SUM-PERMUTATIONS for 2 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.misc:run-permutations "SUM-PERMUTATIONS" 2))

      #-(or lispworks-personal-edition armedbear)
      (progn
        (format t "=== running #<benchmark WALK-LIST/SEQ for 2 runs>~%")
        (force-output)
        (bench-gc)
        (funcall 'cl-bench.misc::setup-walk-list/seq)
        (bench-report 'cl-bench.misc:walk-list/seq "WALK-LIST/SEQ" 2))

      #-(or lispworks-personal-edition armedbear poplog ecl-bytecmp)
      (progn
        (format t "=== running #<benchmark WALK-LIST/MESS for 1 runs>~%")
        (force-output)
        (bench-gc)
        (funcall 'cl-bench.misc::setup-walk-list/mess)
        (bench-report 'cl-bench.misc:walk-list/mess "WALK-LIST/MESS" 1))
      (progn
        (format t "=== running #<benchmark BOYER for 30 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:boyer "BOYER" 30))
      (progn
        (format t "=== running #<benchmark BROWSE for 10 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:browse "BROWSE" 10))
      (progn
        (format t "=== running #<benchmark DDERIV for 50 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:dderiv-run "DDERIV" 50))
      (progn
        (format t "=== running #<benchmark DERIV for 60 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:deriv-run "DERIV" 60))
      (progn
        (format t "=== running #<benchmark DESTRUCTIVE for 100 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:run-destructive "DESTRUCTIVE" 100))
      (progn
        (format t "=== running #<benchmark DIV2-TEST-1 for 200 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:run-div2-test1 "DIV2-TEST-1" 200))
      (progn
        (format t "=== running #<benchmark DIV2-TEST-2 for 200 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:run-div2-test2 "DIV2-TEST-2" 200))
      (progn
        (format t "=== running #<benchmark FFT for 30 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:run-fft "FFT" 30))
      (progn
        (format t "=== running #<benchmark FRPOLY/FIXNUM for 100 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:run-frpoly/fixnum "FRPOLY/FIXNUM" 100))
      (progn
        (format t "=== running #<benchmark FRPOLY/BIGNUM for 30 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:run-frpoly/bignum "FRPOLY/BIGNUM" 30))
      (progn
        (format t "=== running #<benchmark FRPOLY/FLOAT for 100 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:run-frpoly/float "FRPOLY/FLOAT" 100))
      (progn
        (format t "=== running #<benchmark PUZZLE for 1500 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:run-puzzle "PUZZLE" 1500))
      (progn
        (format t "=== running #<benchmark TAK for 500 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:run-tak "TAK" 500))
      (progn
        (format t "=== running #<benchmark CTAK for 900 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:run-ctak "CTAK" 900))
      (progn
        (format t "=== running #<benchmark TRTAK for 500 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:run-trtak "TRTAK" 500))
      (progn
        (format t "=== running #<benchmark TAKL for 150 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:run-takl "TAKL" 150))
      (progn
        (format t "=== running #<benchmark STAK for 200 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:run-stak "STAK" 200))
      (progn
        (format t "=== running #<benchmark FPRINT/UGLY for 200 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:fprint/ugly "FPRINT/UGLY" 200))
      (progn
        (format t "=== running #<benchmark FPRINT/PRETTY for 100 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:fprint/pretty "FPRINT/PRETTY" 100))
      (progn
        (format t "=== running #<benchmark TRAVERSE for 15 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:run-traverse "TRAVERSE" 15))
      (progn
        (format t "=== running #<benchmark TRIANGLE for 5 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.gabriel:run-triangle "TRIANGLE" 5))
      (progn
        (format t "=== running #<benchmark RICHARDS for 5 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.richards:richards "RICHARDS" 5))
      (progn
        (format t "=== running #<benchmark FACTORIAL for 1000 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.math:run-factorial "FACTORIAL" 1000))
      (progn
        (format t "=== running #<benchmark FIB for 50 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.math:run-fib "FIB" 50))
      (progn
        (format t "=== running #<benchmark FIB-RATIO for 500 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.math:run-fib-ratio "FIB-RATIO" 500))
      (progn
        (format t "=== running #<benchmark ACKERMANN for 1 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.math:run-ackermann "ACKERMANN" 1))
      (progn
        (format t "=== running #<benchmark MANDELBROT/COMPLEX for 100 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.math:run-mandelbrot/complex "MANDELBROT/COMPLEX" 100))
      (progn
        (format t "=== running #<benchmark MANDELBROT/DFLOAT for 100 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.math:run-mandelbrot/dfloat "MANDELBROT/DFLOAT" 100))
      (progn
        (format t "=== running #<benchmark MRG32K3A for 20 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.math:run-mrg32k3a "MRG32K3A" 20))
      (progn
        (format t "=== running #<benchmark CRC40 for 2 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.crc:run-crc40 "CRC40" 2))
      (progn
        (format t "=== running #<benchmark BIGNUM/ELEM-100-1000 for 1 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.bignum:run-elem-100-1000 "BIGNUM/ELEM-100-1000" 1))
      (progn
        (format t "=== running #<benchmark BIGNUM/ELEM-1000-100 for 1 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.bignum:run-elem-1000-100 "BIGNUM/ELEM-1000-100" 1))
      (progn
        (format t "=== running #<benchmark BIGNUM/ELEM-10000-1 for 1 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.bignum:run-elem-10000-1 "BIGNUM/ELEM-10000-1" 1))
      (progn
        (format t "=== running #<benchmark BIGNUM/PARI-100-10 for 1 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.bignum:run-pari-100-10 "BIGNUM/PARI-100-10" 1))
      (progn
        (format t "=== running #<benchmark BIGNUM/PARI-200-5 for 1 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.bignum:run-pari-200-5 "BIGNUM/PARI-200-5" 1))
      (progn
        (format t "=== running #<benchmark PI-DECIMAL/SMALL for 100 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.bignum:run-pi-decimal/small "PI-DECIMAL/SMALL" 100))
      (progn
        (format t "=== running #<benchmark PI-DECIMAL/BIG for 2 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.bignum:run-pi-decimal/big "PI-DECIMAL/BIG" 2))
      (progn
        (format t "=== running #<benchmark PI-ATAN for 200 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.bignum:run-pi-atan "PI-ATAN" 200))
      (progn
        (format t "=== running #<benchmark PI-RATIOS for 2 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.ratios:run-pi-ratios "PI-RATIOS" 2))
      (progn
        (format t "=== running #<benchmark HASH-STRINGS for 2 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.hash:hash-strings "HASH-STRINGS" 2))
      (progn
        (format t "=== running #<benchmark HASH-INTEGERS for 10 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.hash:hash-integers "HASH-INTEGERS" 10))
      (progn
        (format t "=== running #<benchmark SLURP-LINES for 30 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.hash:run-slurp-lines "SLURP-LINES" 30))

      #-(or lispworks-personal-edition)
      (progn
        (format t "=== running #<benchmark BOEHM-GC for 1 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.boehm-gc:gc-benchmark "BOEHM-GC" 1))
      (progn
        (format t "=== running #<benchmark DEFLATE-FILE for 100 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.deflate:run-deflate-file "DEFLATE-FILE" 100))

      #-(or lispworks-personal-edition)
      (progn
        (format t "=== running #<benchmark 1D-ARRAYS for 1 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.arrays:bench-1d-arrays "1D-ARRAYS" 1))

      #-(or lispworks-personal-edition)
      (progn
        (format t "=== running #<benchmark 2D-ARRAYS for 1 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.arrays:bench-2d-arrays "2D-ARRAYS" 1))

      #-(or lispworks-personal-edition)
      (progn
        (format t "=== running #<benchmark 3D-ARRAYS for 1 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.arrays:bench-3d-arrays "3D-ARRAYS" 1))
      (progn
        (format t "=== running #<benchmark BITVECTORS for 3 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.arrays:bench-bitvectors "BITVECTORS" 3))

      #-(or lispworks-personal-edition)
      (progn
        (format t "=== running #<benchmark BENCH-STRINGS for 1 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.arrays:bench-strings "BENCH-STRINGS" 1))

      #-(or lispworks-personal-edition)
      (progn
        (format t "=== running #<benchmark fill-strings/adjustable for 1 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.arrays:bench-strings/adjustable "fill-strings/adjustable" 1))

      #-(or allegro lispworks-personal-edition poplog)
      (progn
        (format t "=== running #<benchmark STRING-CONCAT for 1 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.arrays:bench-string-concat "STRING-CONCAT" 1))

      #-(or lispworks-personal-edition)
      (progn
        (format t "=== running #<benchmark SEARCH-SEQUENCE for 1 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.arrays:bench-search-sequence "SEARCH-SEQUENCE" 1))
      (progn
        (format t "=== running #<benchmark CLOS/defclass for 1 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.clos:run-defclass "CLOS/defclass" 1))
      (progn
        (format t "=== running #<benchmark CLOS/defmethod for 1 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.clos:run-defmethod "CLOS/defmethod" 1))
      (progn
        (format t "=== running #<benchmark CLOS/instantiate for 2 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.clos:make-instances "CLOS/instantiate" 2))
      (progn
        (format t "=== running #<benchmark CLOS/simple-instantiate for 200 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.clos:make-instances/simple "CLOS/simple-instantiate" 200))
      (progn
        (format t "=== running #<benchmark CLOS/methodcalls for 5 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.clos:methodcalls/simple "CLOS/methodcalls" 5))
      (progn
        (format t "=== running #<benchmark CLOS/method+after for 2 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.clos:methodcalls/simple+after "CLOS/method+after" 2))

      #-(or clisp poplog)
      (progn
        (format t "=== running #<benchmark CLOS/complex-methods for 5 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.clos:methodcalls/complex "CLOS/complex-methods" 5))
      (progn
        (format t "=== running #<benchmark EQL-SPECIALIZED-FIB for 2 runs>~%")
        (force-output)
        (bench-gc)
        (bench-report 'cl-bench.clos:run-eql-fib "EQL-SPECIALIZED-FIB" 2))
      (bench-report-footer))))