[plt-scheme] Vector / matrix benchmarks
Version 3.
Example code:
(define table-matrix
(table:alist->equal
(list-ec
(:range x 0 20)
(:range y 0 20)
(cons (vector x y) (* x y)))))
(define vector-matrix
(vector-ec
(:range x 0 20)
(:range y 0 20)
(* x y)))
(define (table-multiply)
(sum-ec
(:range row 0 20)
(:range col 0 20)
(:range elt 0 20)
(* (table:lookup (vector row elt) table-matrix)
(table:lookup (vector col elt) table-matrix))))
(define (vector-multiply)
(sum-ec
(:range row 0 20)
(:range col 0 20)
(:range elt 0 20)
(* (vector-ref vector-matrix (+ (* row 20) elt))
(vector-ref vector-matrix (+ (* elt 20) col)))))
(test-case
"Ensure vectors are faster than tables"
(check-faster table-multiply vector-multiply))
Check-faster is defined in the benchmark library in the
Schematics svn.
N.
--- Carl Eastlund <cce at ccs.neu.edu> wrote:
>
> Out of curiosity, Galore version 2 or Galore version 3?
>
> --
> Carl Eastlund
>
Email: noelwelsh <at> yahoo <dot> com noel <at> untyped <dot> com
AIM: noelhwelsh
Blogs: http://monospaced.blogspot.com/ http://www.untyped.com/untyping/
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com