2009-01-09 03:40:55 -05:00
|
|
|
;;; Ikarus Scheme -- A compiler for R6RS Scheme.
|
|
|
|
;;; Copyright (C) 2006,2007,2008 Abdulaziz Ghuloum
|
|
|
|
;;;
|
|
|
|
;;; This program is free software: you can redistribute it and/or modify
|
|
|
|
;;; it under the terms of the GNU General Public License version 3 as
|
|
|
|
;;; published by the Free Software Foundation.
|
|
|
|
;;;
|
|
|
|
;;; This program is distributed in the hope that it will be useful, but
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
;;; General Public License for more details.
|
|
|
|
;;;
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2007-06-13 03:14:14 -04:00
|
|
|
|
2007-11-04 12:03:32 -05:00
|
|
|
(library (rnrs-benchmarks)
|
2007-06-13 10:49:54 -04:00
|
|
|
(export run-benchmark fatal-error include-source
|
2007-11-04 17:00:11 -05:00
|
|
|
call-with-output-file/truncate fast-run
|
2007-06-13 03:19:16 -04:00
|
|
|
ack-iters
|
2007-06-13 07:17:57 -04:00
|
|
|
array1-iters
|
2007-11-11 02:10:02 -05:00
|
|
|
bibfreq-iters
|
2007-06-13 07:17:57 -04:00
|
|
|
boyer-iters
|
|
|
|
browse-iters
|
|
|
|
cat-iters
|
2007-11-04 17:00:11 -05:00
|
|
|
compiler-iters
|
2007-06-13 07:17:57 -04:00
|
|
|
conform-iters
|
|
|
|
cpstak-iters
|
|
|
|
ctak-iters
|
|
|
|
dderiv-iters
|
|
|
|
deriv-iters
|
|
|
|
destruc-iters
|
|
|
|
diviter-iters
|
|
|
|
divrec-iters
|
|
|
|
dynamic-iters
|
|
|
|
earley-iters
|
2007-06-18 11:04:02 -04:00
|
|
|
fft-iters
|
2007-06-13 07:17:57 -04:00
|
|
|
fib-iters
|
|
|
|
fibc-iters
|
|
|
|
fibfp-iters
|
2007-06-13 10:49:54 -04:00
|
|
|
fpsum-iters
|
2007-06-13 07:17:57 -04:00
|
|
|
gcbench-iters
|
|
|
|
gcold-iters
|
|
|
|
graphs-iters
|
|
|
|
lattice-iters
|
|
|
|
matrix-iters
|
2007-11-04 12:03:32 -05:00
|
|
|
maze-iters
|
2007-06-13 07:17:57 -04:00
|
|
|
mazefun-iters
|
|
|
|
mbrot-iters
|
2007-11-04 12:03:32 -05:00
|
|
|
nbody-iters
|
2007-06-13 07:17:57 -04:00
|
|
|
nboyer-iters
|
|
|
|
nqueens-iters
|
2007-11-05 22:49:38 -05:00
|
|
|
ntakl-iters
|
2007-06-13 11:17:21 -04:00
|
|
|
nucleic-iters
|
2007-06-13 07:17:57 -04:00
|
|
|
takl-iters
|
|
|
|
paraffins-iters
|
|
|
|
parsing-iters
|
|
|
|
perm9-iters
|
|
|
|
pnpoly-iters
|
|
|
|
peval-iters
|
2007-06-13 10:49:54 -04:00
|
|
|
pi-iters
|
|
|
|
primes-iters
|
|
|
|
puzzle-iters
|
|
|
|
quicksort-iters
|
2007-06-18 07:06:13 -04:00
|
|
|
ray-iters
|
2007-06-13 10:49:54 -04:00
|
|
|
sboyer-iters
|
2007-11-04 12:03:32 -05:00
|
|
|
scheme-iters
|
2007-06-16 02:59:39 -04:00
|
|
|
simplex-iters
|
2007-09-15 00:14:47 -04:00
|
|
|
slatex-iters
|
2007-06-13 10:49:54 -04:00
|
|
|
sum-iters
|
|
|
|
sum1-iters
|
|
|
|
string-iters
|
|
|
|
sumfp-iters
|
|
|
|
sumloop-iters
|
|
|
|
tail-iters
|
|
|
|
tak-iters
|
|
|
|
trav1-iters
|
|
|
|
trav2-iters
|
|
|
|
triangl-iters
|
|
|
|
wc-iters)
|
|
|
|
|
2007-06-13 03:14:14 -04:00
|
|
|
(import (ikarus))
|
2007-06-13 07:17:57 -04:00
|
|
|
|
2007-06-13 10:49:54 -04:00
|
|
|
(define call-with-output-file/truncate
|
|
|
|
(lambda (file-name proc)
|
2007-12-25 05:03:41 -05:00
|
|
|
(let ([p (open-file-output-port
|
|
|
|
file-name
|
|
|
|
(file-options no-fail)
|
|
|
|
'block
|
|
|
|
(native-transcoder))])
|
|
|
|
(call-with-port p proc))))
|
2007-06-13 10:49:54 -04:00
|
|
|
|
2007-06-13 07:17:57 -04:00
|
|
|
(define-syntax include-source
|
|
|
|
(lambda (x)
|
|
|
|
(syntax-case x ()
|
|
|
|
[(ctxt name)
|
|
|
|
(cons #'begin
|
|
|
|
(with-input-from-file
|
2007-11-04 17:00:11 -05:00
|
|
|
(format "rnrs-benchmarks/~a" (syntax->datum #'name))
|
2007-06-13 07:17:57 -04:00
|
|
|
(lambda ()
|
|
|
|
(let f ()
|
|
|
|
(let ([x (read)])
|
|
|
|
(cond
|
|
|
|
[(eof-object? x) '()]
|
|
|
|
[else
|
|
|
|
(cons (datum->syntax #'ctxt x) (f))]))))))])))
|
|
|
|
|
|
|
|
(define (fatal-error . args)
|
|
|
|
(error 'fatal-error "~a"
|
|
|
|
(apply (lambda (x) (format "~a" x)) args)))
|
2007-11-04 17:00:11 -05:00
|
|
|
|
|
|
|
(define fast-run (make-parameter #f))
|
2007-06-13 03:14:14 -04:00
|
|
|
|
|
|
|
(define (run-bench count run)
|
2007-11-17 12:53:37 -05:00
|
|
|
(import (ikarus system $fx))
|
|
|
|
(unless ($fx= count 0)
|
|
|
|
(let f ([count ($fx- count 1)] [run run])
|
2007-06-13 03:14:14 -04:00
|
|
|
(cond
|
2007-11-17 12:53:37 -05:00
|
|
|
[($fx= count 0) (run)]
|
2007-06-13 03:14:14 -04:00
|
|
|
[else
|
2007-11-17 12:53:37 -05:00
|
|
|
(begin (run) (f ($fx- count 1) run))]))))
|
2007-06-13 03:14:14 -04:00
|
|
|
|
|
|
|
(define (run-benchmark name count ok? run-maker . args)
|
|
|
|
(let ([run (apply run-maker args)])
|
|
|
|
(let ([result
|
2007-11-05 22:49:38 -05:00
|
|
|
(time-it (format "~a (~a)" name count)
|
2007-11-04 17:00:11 -05:00
|
|
|
(if (fast-run)
|
|
|
|
run
|
|
|
|
(lambda () (run-bench count run))))])
|
2007-06-13 03:14:14 -04:00
|
|
|
(unless (ok? result)
|
|
|
|
(error #f "*** wrong result ***")))))
|
|
|
|
|
|
|
|
|
|
|
|
; Gabriel benchmarks
|
2007-11-05 22:49:38 -05:00
|
|
|
(define boyer-iters 50)
|
2007-06-13 03:14:14 -04:00
|
|
|
(define browse-iters 600)
|
2007-11-05 22:49:38 -05:00
|
|
|
(define cpstak-iters 1700)
|
|
|
|
(define ctak-iters 160)
|
|
|
|
(define dderiv-iters 3000000)
|
|
|
|
(define deriv-iters 4000000)
|
|
|
|
(define destruc-iters 800)
|
|
|
|
(define diviter-iters 1200000)
|
|
|
|
(define divrec-iters 1200000)
|
|
|
|
(define puzzle-iters 180)
|
|
|
|
(define tak-iters 3000)
|
|
|
|
(define takl-iters 500)
|
|
|
|
(define trav1-iters 150)
|
|
|
|
(define trav2-iters 40)
|
|
|
|
(define triangl-iters 12)
|
2007-06-13 03:14:14 -04:00
|
|
|
; Kernighan and Van Wyk benchmarks
|
2007-11-05 22:49:38 -05:00
|
|
|
(define ack-iters 20)
|
|
|
|
(define array1-iters 2)
|
|
|
|
(define cat-iters 12)
|
|
|
|
(define string-iters 4)
|
|
|
|
(define sum1-iters 5)
|
|
|
|
(define sumloop-iters 2)
|
|
|
|
(define tail-iters 4)
|
|
|
|
(define wc-iters 15)
|
2007-06-13 03:14:14 -04:00
|
|
|
|
|
|
|
; C benchmarks
|
2007-11-05 22:49:38 -05:00
|
|
|
(define fft-iters 4000)
|
|
|
|
(define fib-iters 6)
|
2007-06-13 03:14:14 -04:00
|
|
|
(define fibfp-iters 2)
|
2007-11-06 01:14:27 -05:00
|
|
|
(define mbrot-iters 120)
|
2007-11-05 22:49:38 -05:00
|
|
|
(define nucleic-iters 12)
|
|
|
|
(define pnpoly-iters 140000)
|
|
|
|
(define sum-iters 30000)
|
|
|
|
(define sumfp-iters 8000)
|
2007-06-13 03:14:14 -04:00
|
|
|
(define tfib-iters 20)
|
|
|
|
|
|
|
|
; Other benchmarks
|
2007-11-05 22:49:38 -05:00
|
|
|
(define conform-iters 70)
|
|
|
|
(define dynamic-iters 70)
|
|
|
|
(define earley-iters 400)
|
|
|
|
(define fibc-iters 900)
|
|
|
|
(define graphs-iters 500)
|
|
|
|
(define lattice-iters 2)
|
|
|
|
(define matrix-iters 600)
|
2007-06-13 03:14:14 -04:00
|
|
|
(define maze-iters 4000)
|
2007-11-05 22:49:38 -05:00
|
|
|
(define mazefun-iters 2500)
|
|
|
|
(define nqueens-iters 4000)
|
|
|
|
(define ntakl-iters 600)
|
|
|
|
(define paraffins-iters 1800)
|
|
|
|
(define peval-iters 400)
|
|
|
|
(define pi-iters 3)
|
|
|
|
(define primes-iters 180000)
|
2007-11-13 12:21:27 -05:00
|
|
|
(define ray-iters 5)
|
2007-11-05 22:49:38 -05:00
|
|
|
(define scheme-iters 40000)
|
|
|
|
(define simplex-iters 160000)
|
|
|
|
(define slatex-iters 30)
|
|
|
|
(define perm9-iters 12)
|
|
|
|
(define nboyer-iters 150)
|
|
|
|
(define sboyer-iters 200)
|
|
|
|
(define gcbench-iters 2)
|
|
|
|
(define compiler-iters 500)
|
2007-06-13 03:14:14 -04:00
|
|
|
|
|
|
|
; New benchmarks
|
2007-11-05 22:49:38 -05:00
|
|
|
(define parsing-iters 360)
|
|
|
|
(define gcold-iters 600)
|
2007-06-13 10:49:54 -04:00
|
|
|
|
2007-11-05 22:49:38 -05:00
|
|
|
(define quicksort-iters 60)
|
|
|
|
(define fpsum-iters 60)
|
2007-11-11 02:10:02 -05:00
|
|
|
(define nbody-iters 1)
|
|
|
|
(define bibfreq-iters 2)
|
2007-11-05 22:49:38 -05:00
|
|
|
)
|
2007-06-13 03:14:14 -04:00
|
|
|
|