benchmark.sum-file: removing dependency on random.

db4
John Benediktsson 2012-07-27 15:44:38 -07:00
parent 916c495337
commit 2d5a141ef5
1 changed files with 13 additions and 5 deletions

View File

@ -1,14 +1,22 @@
USING: io io.files math math.parser kernel prettyprint USING: io io.encodings.ascii io.files io.files.temp math
benchmark.random io.encodings.ascii ; math.parser kernel sequences ;
IN: benchmark.sum-file IN: benchmark.sum-file
<<
"sum-file.txt" temp-file ascii [
100000 iota [ number>string print ] each
] with-file-writer
>>
: sum-file-loop ( n -- n' ) : sum-file-loop ( n -- n' )
readln [ string>number + sum-file-loop ] when* ; readln [ string>number + sum-file-loop ] when* ;
: sum-file ( file -- ) : sum-file ( file -- n )
ascii [ 0 sum-file-loop ] with-file-reader . ; ascii [ 0 sum-file-loop ] with-file-reader ;
: sum-file-benchmark ( -- ) : sum-file-benchmark ( -- )
5 [ random-numbers-path sum-file ] times ; 15 [
"sum-file.txt" temp-file sum-file 4999950000 assert=
] times ;
MAIN: sum-file-benchmark MAIN: sum-file-benchmark