factor/extra/benchmark/sum-file/sum-file.factor

23 lines
511 B
Factor
Raw Normal View History

USING: io io.encodings.ascii io.files io.files.temp math
math.parser kernel sequences ;
2007-09-20 18:09:08 -04:00
IN: benchmark.sum-file
<<
"sum-file.txt" temp-file ascii [
100000 iota [ number>string print ] each
] with-file-writer
>>
2007-09-20 18:09:08 -04:00
: sum-file-loop ( n -- n' )
readln [ string>number + sum-file-loop ] when* ;
: sum-file ( file -- n )
ascii [ 0 sum-file-loop ] with-file-reader ;
2007-09-20 18:09:08 -04:00
: sum-file-benchmark ( -- )
15 [
"sum-file.txt" temp-file sum-file 4999950000 assert=
] times ;
2007-09-20 18:09:08 -04:00
MAIN: sum-file-benchmark