benchmark.file-server hit the array-capacity limit, so lower the #bytes sent by one and add a #times parameter
parent
c73724d273
commit
4cbbfe82aa
|
@ -1,10 +1,14 @@
|
||||||
! Copyright (C) 2011 Doug Coleman.
|
! Copyright (C) 2011 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors byte-arrays io io.encodings.binary io.servers
|
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
|
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 )
|
MEMO: test-file-bytes ( -- byte-array )
|
||||||
test-file-size iota >byte-array ;
|
test-file-size iota >byte-array ;
|
||||||
|
@ -16,7 +20,8 @@ TUPLE: file-server < threaded-server ;
|
||||||
f 0 <inet4> >>insecure ;
|
f 0 <inet4> >>insecure ;
|
||||||
|
|
||||||
M: file-server handle-client*
|
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 ;
|
ERROR: incorrect-#bytes ;
|
||||||
|
|
||||||
|
@ -25,8 +30,15 @@ ERROR: incorrect-#bytes ;
|
||||||
|
|
||||||
: file-server-benchmark ( -- )
|
: file-server-benchmark ( -- )
|
||||||
<file-server> start-server [
|
<file-server> start-server [
|
||||||
server>address binary <client> drop
|
[ #times ] dip
|
||||||
stream-contents length test-file-size = [ incorrect-#bytes ] unless
|
server>address binary <client> 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 ;
|
] [ stop-server ] bi ;
|
||||||
|
|
||||||
MAIN: file-server-benchmark
|
MAIN: file-server-benchmark
|
Loading…
Reference in New Issue