New sockets benchmark

db4
Slava Pestov 2008-02-11 15:53:42 -06:00
parent 7fa7ed962f
commit c6be6bcfdf
1 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,29 @@
USING: io.sockets io.server io kernel math threads debugger
concurrency tools.time prettyprint ;
IN: benchmark.sockets
: simple-server ( -- )
7777 local-server "simple-server" [
10 [ read1 write1 flush ] times
] with-server ;
: simple-client ( -- )
"localhost" 7777 <inet> <client> [
10 [ CHAR: a dup write1 flush read1 assert= ] times
] with-stream ;
: socket-benchmark ( n -- )
dup pprint " clients: " write
[ simple-server ] in-thread
yield yield
[ drop simple-client ] parallel-each ;
: socket-benchmarks
[ 10 socket-benchmark ] time
[ 20 socket-benchmark ] time
[ 40 socket-benchmark ] time
[ 80 socket-benchmark ] time
[ 160 socket-benchmark ] time
[ 320 socket-benchmark ] time ;
MAIN: socket-benchmarks