mostly improvements to run.ss benchmark-running script

svn: r5423
This commit is contained in:
Matthew Flatt 2007-01-22 03:18:51 +00:00
parent ab98b01677
commit b550ae9b73
3 changed files with 1076 additions and 28 deletions

View File

@ -43,7 +43,7 @@
(if (eof-object? l) (if (eof-object? l)
(output accum) (output accum)
(cond (cond
[(regexp-match #rx#"^>" l) [(regexp-match? #rx#"^>" l)
(output accum) (output accum)
(printf "~a\n" l) (printf "~a\n" l)
(loop null)] (loop null)]

View File

@ -1,54 +1,102 @@
(module run mzscheme (module run mzscheme
(define input-map (define input-map
'( `(
("ackermann.ss" . "11") ("ackermann.ss" "11")
("ary.ss" . "9000") ("ary.ss" "9000")
("binarytrees.ss" . "16") ("binarytrees.ss" "16")
("chameneos.ss") ("chameneos.ss")
("cheapconcurrency.ss") ("cheapconcurrency.ss")
("echo.ss" . "150000") ("echo.ss" "150000")
("except.ss" . "2500000") ("except.ss" "2500000")
("fannkuch.ss" . "10") ("fannkuch.ss" "10")
("fasta.ss") ("fasta.ss" "25000000")
("fibo.ss" . "32") ("fibo.ss" "32")
("hash.ss" . "100000") ("hash.ss" "100000")
("hash2.ss" . "200") ("hash2.ss" "200")
("heapsort.ss" . "100000") ("heapsort.ss" "100000")
("lists.ss" . "18") ("lists.ss" "18")
("mandelbrot.ss") ("mandelbrot.ss")
("matrix.ss" . "600") ("matrix.ss" "600")
("moments.ss") 200 somethings... ("moments.ss") ; 200 somethings...
("nbody.ss") ("nbody.ss")
("nestedloop.ss" . "18") ("nestedloop.ss" "18")
("nsieve.ss") ("nsieve.ss")
("nsievebits.ss") ("nsievebits.ss")
("partialsums.ss") ("partialsums.ss")
("pidigits.ss") ("pidigits.ss")
("pidigits1.ss") ("pidigits1.ss")
("random.ss" . "900000") ("random.ss" "900000")
("recursive.ss") ("recursive.ss")
("regexmatch.ss") ("regexmatch.ss")
("regexpdna.ss") ("regexpdna.ss")
("reversecomplement.ss") ("reversecomplement.ss" #f ,(lambda () (mk-revcomp-input)))
("reversefile.ss") ("reversefile.ss")
("sieve.ss" . "1200") ("sieve.ss" "1200")
("spellcheck.ss") ("spellcheck.ss")
("strcat.ss" . "40000") ("strcat.ss" "40000")
("sumcol.ss") ("sumcol.ss" #f ,(lambda () (mk-sumcol-input)))
("wc.ss") ("wc.ss")
("wordfreq.ss") ("wordfreq.ss")
)) ))
(let ([len (vector-length (current-command-line-arguments))]) (define (dynreq f)
(unless (= 1 len) (dynamic-require `(lib ,f "tests" "mzscheme" "benchmarks" "shootout") #f))
(error 'run "provide ~athe name of a benchmark on the command line"
(if (zero? len) "" "ONLY "))))
(define (mk-revcomp-input)
(let ([f (build-path (find-system-path 'temp-dir) "fasta-2m5")])
(unless (file-exists? f)
(printf "Building FASTA 2,500,000 output for input: ~a\n" f)
(with-output-to-file f
(lambda ()
(parameterize ([current-command-line-arguments (vector "2500000")])
(dynreq "fasta.ss")))))
f))
(define (mk-sumcol-input)
(let ([f (build-path (find-system-path 'temp-dir) "sumcol-21k")])
(unless (file-exists? f)
(printf "Building sumcol 21000 input: ~a\n" f)
(let ([c (with-input-from-file (build-path (collection-path "tests")
"mzscheme"
"benchmarks"
"shootout"
"sumcol-input.txt")
(lambda ()
(read-bytes 10000)))])
(with-output-to-file f
(lambda ()
(let loop ([n 21000])
(unless (zero? n)
(printf "~a" c)
(loop (sub1 n))))))))
f))
(define iters
(let ([len (vector-length (current-command-line-arguments))])
(unless (<= 1 len 2)
(error 'run "provide ~athe name of a benchmark on the command line and an optional iteration count"
(if (zero? len) "" "ONLY ")))
(if (= len 2)
(string->number (vector-ref (current-command-line-arguments) 1))
1)))
(let ([prog (vector-ref (current-command-line-arguments) 0)]) (let ([prog (vector-ref (current-command-line-arguments) 0)])
(let ([m (assoc prog input-map)]) (let ([m (assoc prog input-map)])
(unless m (unless m
(error 'run "cannot find input for ~a" prog)) (error 'run "cannot find input for ~a" prog))
(when (null? (cdr m)) (when (null? (cdr m))
(error 'run "don't know input for ~a" prog)) (error 'run "don't know input for ~a" prog))
(parameterize ([current-command-line-arguments (vector (cdr m))]) (let loop ([n iters])
(time (dynamic-require prog #f)))))) (parameterize ([current-command-line-arguments
(if (cadr m)
(vector (cadr m))
(vector))]
[current-input-port
(if (null? (cddr m))
(current-input-port)
(open-input-file ((caddr m))))])
(parameterize ([current-namespace (make-namespace)])
(collect-garbage)
(time (dynreq prog))))
(unless (= n 1)
(loop (sub1 n)))))))

File diff suppressed because it is too large Load Diff