Fix benchmarks

db4
Slava Pestov 2008-03-11 21:58:50 -05:00
parent 01ec501f83
commit ce600b6aec
5 changed files with 19 additions and 17 deletions
extra/benchmark

4
extra/benchmark/crc32/crc32.factor Normal file → Executable file
View File

@ -1,10 +1,10 @@
USING: io.crc32 io.files kernel math ;
USING: io.crc32 io.encodings.ascii io.files kernel math ;
IN: benchmark.crc32
: crc32-primes-list ( -- )
10 [
"extra/math/primes/list/list.factor" resource-path
file-contents crc32 drop
ascii file-contents crc32 drop
] times ;
MAIN: crc32-primes-list

View File

@ -1,7 +1,7 @@
IN: benchmark.mandel
USING: arrays io kernel math namespaces sequences strings sbufs
math.functions math.parser io.files colors.hsv
io.encodings.ascii ;
USING: arrays io kernel math namespaces sequences
byte-arrays byte-vectors math.functions math.parser io.files
colors.hsv io.encodings.binary ;
: max-color 360 ; inline
: zoom-fact 0.8 ; inline
@ -54,18 +54,18 @@ SYMBOL: cols
: ppm-header ( w h -- )
"P6\n" % swap # " " % # "\n255\n" % ;
: sbuf-size width height * 3 * 100 + ;
: buf-size width height * 3 * 100 + ;
: mandel ( -- string )
: mandel ( -- data )
[
sbuf-size <sbuf> building set
buf-size <byte-vector> building set
width height ppm-header
nb-iter max-color min <color-map> cols set
render
building get >string
building get >byte-array
] with-scope ;
: mandel-main ( -- )
mandel "mandel.ppm" temp-file ascii set-file-contents ;
mandel "mandel.ppm" temp-file binary set-file-contents ;
MAIN: mandel-main

4
extra/benchmark/random/random.factor Normal file → Executable file
View File

@ -1,10 +1,10 @@
USING: io.files random math.parser io math ;
USING: io.files io.encodings.ascii random math.parser io math ;
IN: benchmark.random
: random-numbers-path "random-numbers.txt" temp-file ;
: write-random-numbers ( n -- )
random-numbers-path [
random-numbers-path ascii [
[ 200 random 100 - number>string print ] times
] with-file-writer ;

6
extra/benchmark/raytracer/raytracer.factor Normal file → Executable file
View File

@ -3,7 +3,7 @@
USING: float-arrays compiler generic io io.files kernel math
math.functions math.vectors math.parser namespaces sequences
sequences.private words io.encodings.ascii ;
sequences.private words io.encodings.binary ;
IN: benchmark.raytracer
! parameters
@ -167,9 +167,9 @@ DEFER: create ( level c r -- scene )
levels { 0.0 -1.0 0.0 } 1.0 create ray-trace [
size size pgm-header
[ [ oversampling sq / pgm-pixel ] each ] each
] "" make ;
] B{ } make ;
: raytracer-main
run "raytracer.pnm" temp-file ascii set-file-contents ;
run "raytracer.pnm" temp-file binary set-file-contents ;
MAIN: raytracer-main

6
extra/benchmark/sort/sort.factor Normal file → Executable file
View File

@ -1,8 +1,10 @@
USING: kernel sequences sorting benchmark.random math.parser
io.files ;
io.files io.encodings.ascii ;
IN: benchmark.sort
: sort-benchmark
random-numbers-path file-lines [ string>number ] map natural-sort drop ;
random-numbers-path
ascii file-lines [ string>number ] map
natural-sort drop ;
MAIN: sort-benchmark