implement missing bm
svn: r5496
This commit is contained in:
parent
495ec85d97
commit
052e2c3896
|
@ -5,7 +5,7 @@
|
||||||
("ary.ss" "9000")
|
("ary.ss" "9000")
|
||||||
("binarytrees.ss" "16")
|
("binarytrees.ss" "16")
|
||||||
("chameneos.ss")
|
("chameneos.ss")
|
||||||
("cheapconcurrency.ss")
|
("cheapconcurrency.ss" "15000")
|
||||||
("echo.ss" "150000")
|
("echo.ss" "150000")
|
||||||
("except.ss" "2500000")
|
("except.ss" "2500000")
|
||||||
("fannkuch.ss" "10")
|
("fannkuch.ss" "10")
|
||||||
|
@ -15,10 +15,10 @@
|
||||||
("hash2.ss" "200")
|
("hash2.ss" "200")
|
||||||
("heapsort.ss" "100000")
|
("heapsort.ss" "100000")
|
||||||
("lists.ss" "18")
|
("lists.ss" "18")
|
||||||
("mandelbrot.ss")
|
("mandelbrot.ss" "3000")
|
||||||
("matrix.ss" "600")
|
("matrix.ss" "600")
|
||||||
("moments.ss") ; 200 somethings...
|
("moments.ss") ; 200 somethings...
|
||||||
("nbody.ss")
|
("nbody.ss" "20000000")
|
||||||
("nestedloop.ss" "18")
|
("nestedloop.ss" "18")
|
||||||
("nsieve.ss")
|
("nsieve.ss")
|
||||||
("nsievebits.ss")
|
("nsievebits.ss")
|
||||||
|
@ -42,16 +42,22 @@
|
||||||
(define (dynreq f)
|
(define (dynreq f)
|
||||||
(dynamic-require `(lib ,f "tests" "mzscheme" "benchmarks" "shootout") #f))
|
(dynamic-require `(lib ,f "tests" "mzscheme" "benchmarks" "shootout") #f))
|
||||||
|
|
||||||
(define (mk-revcomp-input)
|
(define (mk-fasta n suffix)
|
||||||
(let ([f (build-path (find-system-path 'temp-dir) "fasta-2m5")])
|
(let ([f (build-path (find-system-path 'temp-dir) (string-append "fasta-" suffix))])
|
||||||
(unless (file-exists? f)
|
(unless (file-exists? f)
|
||||||
(printf "Building FASTA 2,500,000 output for input: ~a\n" f)
|
(printf "Building FASTA ~a output for input: ~a\n" n f)
|
||||||
(with-output-to-file f
|
(with-output-to-file f
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(parameterize ([current-command-line-arguments (vector "2500000")])
|
(parameterize ([current-command-line-arguments (vector n)])
|
||||||
(dynreq "fasta.ss")))))
|
(dynreq "fasta.ss")))))
|
||||||
f))
|
f))
|
||||||
|
|
||||||
|
(define (mk-revcomp-input)
|
||||||
|
(mk-fasta "2500000" "2m5"))
|
||||||
|
|
||||||
|
(define (mk-knuc-input)
|
||||||
|
(mk-fasta "1000000" "1m"))
|
||||||
|
|
||||||
(define (mk-sumcol-input)
|
(define (mk-sumcol-input)
|
||||||
(let ([f (build-path (find-system-path 'temp-dir) "sumcol-21k")])
|
(let ([f (build-path (find-system-path 'temp-dir) "sumcol-21k")])
|
||||||
(unless (file-exists? f)
|
(unless (file-exists? f)
|
||||||
|
|
72
collects/tests/mzscheme/benchmarks/shootout/spectralnorm.ss
Normal file
72
collects/tests/mzscheme/benchmarks/shootout/spectralnorm.ss
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
;; The Computer Language Shootout
|
||||||
|
;; http://shootout.alioth.debian.org/
|
||||||
|
;;
|
||||||
|
;; Based on the Ruby version:
|
||||||
|
#|
|
||||||
|
# http://shootout.alioth.debian.org
|
||||||
|
#
|
||||||
|
# contributed by jose fco. gonzalez
|
||||||
|
# modified by Sokolov Yura
|
||||||
|
|#
|
||||||
|
|
||||||
|
(module spectralnorm mzscheme
|
||||||
|
(require (lib "list.ss")
|
||||||
|
(lib "string.ss")
|
||||||
|
(only (lib "13.ss" "srfi") string-pad-right))
|
||||||
|
|
||||||
|
(define (all-counts len dna)
|
||||||
|
(let ([table (make-hash-table)]
|
||||||
|
[seq (make-string len)])
|
||||||
|
(let loop ([s (- (string-length dna) len)])
|
||||||
|
(string-copy! seq 0 dna s (+ s len))
|
||||||
|
(let ([key (string->symbol seq)])
|
||||||
|
(let ([cnt (hash-table-get table key 0)])
|
||||||
|
(hash-table-put! table key (add1 cnt))))
|
||||||
|
(unless (zero? s)
|
||||||
|
(loop (sub1 s))))
|
||||||
|
table))
|
||||||
|
|
||||||
|
(define (write-freqs table)
|
||||||
|
(let* ([content (hash-table-map table cons)]
|
||||||
|
[total (exact->inexact (apply + (map cdr content)))])
|
||||||
|
(for-each
|
||||||
|
(lambda (a)
|
||||||
|
(printf "~a ~a\n"
|
||||||
|
(car a)
|
||||||
|
(real->decimal-string (* 100 (/ (cdr a) total)) 3)))
|
||||||
|
(sort content (lambda (a b) (> (cdr a) (cdr b)))))))
|
||||||
|
|
||||||
|
(define (write-one-freq table key)
|
||||||
|
(let ([cnt (hash-table-get table key 0)])
|
||||||
|
(printf "~a\t~a\n" cnt key)))
|
||||||
|
|
||||||
|
(define dna
|
||||||
|
(begin
|
||||||
|
;; Skip to ">THREE ..."
|
||||||
|
(regexp-match #rx#"(?m:^>THREE.*$)" (current-input-port))
|
||||||
|
(let ([s (open-output-string)])
|
||||||
|
;; Copy everything but newlines to s:
|
||||||
|
(let loop ()
|
||||||
|
(when (regexp-match #rx#"\n" (current-input-port) 0 #f s)
|
||||||
|
(loop)))
|
||||||
|
;; Extract the string from s:
|
||||||
|
(string-upcase (get-output-string s)))))
|
||||||
|
|
||||||
|
;; 1-nucleotide counts:
|
||||||
|
(write-freqs (all-counts 1 dna))
|
||||||
|
(newline)
|
||||||
|
|
||||||
|
;; 2-nucleotide counts:
|
||||||
|
(write-freqs (all-counts 2 dna))
|
||||||
|
(newline)
|
||||||
|
|
||||||
|
;; Specific sequences:
|
||||||
|
(for-each (lambda (seq)
|
||||||
|
(write-one-freq (all-counts (string-length seq) dna)
|
||||||
|
(string->symbol seq)))
|
||||||
|
'("GGT" "GGTA" "GGTATT" "GGTATTTTAATT" "GGTATTTTAATTTATAGT"))
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user