Improved sockets benchmark
parent
80c9fe3c83
commit
5c0374ce32
|
@ -3,27 +3,41 @@ concurrency tools.time prettyprint ;
|
||||||
IN: benchmark.sockets
|
IN: benchmark.sockets
|
||||||
|
|
||||||
: simple-server ( -- )
|
: simple-server ( -- )
|
||||||
7777 local-server "simple-server" [
|
7777 local-server "benchmark.sockets" [
|
||||||
10 [ read1 write1 flush ] times
|
read1 CHAR: x = [
|
||||||
|
stop-server
|
||||||
|
] [
|
||||||
|
20 [ read1 write1 flush ] times
|
||||||
|
] if
|
||||||
] with-server ;
|
] with-server ;
|
||||||
|
|
||||||
: simple-client ( -- )
|
: simple-client ( -- )
|
||||||
"localhost" 7777 <inet> <client> [
|
"localhost" 7777 <inet> <client> [
|
||||||
10 [ CHAR: a dup write1 flush read1 assert= ] times
|
CHAR: b write1 flush
|
||||||
|
20 [ CHAR: a dup write1 flush read1 assert= ] times
|
||||||
|
] with-stream ;
|
||||||
|
|
||||||
|
: stop-server ( -- )
|
||||||
|
"localhost" 7777 <inet> <client> [
|
||||||
|
CHAR: x write1
|
||||||
] with-stream ;
|
] with-stream ;
|
||||||
|
|
||||||
: socket-benchmark ( n -- )
|
: socket-benchmark ( n -- )
|
||||||
dup pprint " clients: " write
|
dup pprint " clients: " write
|
||||||
|
[
|
||||||
[ simple-server ] in-thread
|
[ simple-server ] in-thread
|
||||||
|
100 sleep
|
||||||
|
[ drop simple-client ] parallel-each
|
||||||
|
stop-server
|
||||||
yield yield
|
yield yield
|
||||||
[ drop simple-client ] parallel-each ;
|
] time ;
|
||||||
|
|
||||||
: socket-benchmarks
|
: socket-benchmarks
|
||||||
[ 10 socket-benchmark ] time
|
10 socket-benchmark
|
||||||
[ 20 socket-benchmark ] time
|
20 socket-benchmark
|
||||||
[ 40 socket-benchmark ] time
|
40 socket-benchmark
|
||||||
[ 80 socket-benchmark ] time
|
80 socket-benchmark
|
||||||
[ 160 socket-benchmark ] time
|
160 socket-benchmark
|
||||||
[ 320 socket-benchmark ] time ;
|
320 socket-benchmark ;
|
||||||
|
|
||||||
MAIN: socket-benchmarks
|
MAIN: socket-benchmarks
|
||||||
|
|
Loading…
Reference in New Issue