diff --git a/extra/benchmark/file-server/file-server.factor b/extra/benchmark/file-server/file-server.factor index 028998e586..8dea55fa6e 100644 --- a/extra/benchmark/file-server/file-server.factor +++ b/extra/benchmark/file-server/file-server.factor @@ -1,10 +1,14 @@ ! Copyright (C) 2011 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors byte-arrays io io.encodings.binary io.servers -io.sockets kernel math memoize namespaces sequences ; +io.sockets kernel math memoize namespaces sequences fry literals ; IN: benchmark.file-server -: test-file-size ( -- n ) 26 2^ ; +! Tweak these parameters to test different loads +CONSTANT: #times 4 + +! Max size here is 26 2^ 1 - because array-capacity limits on 32bit platforms +CONSTANT: test-file-size $[ 26 2^ 1 - ] MEMO: test-file-bytes ( -- byte-array ) test-file-size iota >byte-array ; @@ -16,7 +20,8 @@ TUPLE: file-server < threaded-server ; f 0 >>insecure ; M: file-server handle-client* - drop test-file-bytes output-stream get stream-write ; + drop + #times [ test-file-bytes output-stream get stream-write ] times ; ERROR: incorrect-#bytes ; @@ -25,8 +30,15 @@ ERROR: incorrect-#bytes ; : file-server-benchmark ( -- ) start-server [ - server>address binary drop - stream-contents length test-file-size = [ incorrect-#bytes ] unless + [ #times ] dip + server>address binary drop [ + '[ + test-file-size _ stream-read length test-file-size = + [ incorrect-#bytes ] unless + ] times + ] [ + stream-contents length 0 = [ incorrect-#bytes ] unless + ] bi ] [ stop-server ] bi ; -MAIN: file-server-benchmark \ No newline at end of file +MAIN: file-server-benchmark