Skip to content

Commit

Permalink
Send a sentinel byte from the TCP server to the client to signal end …
Browse files Browse the repository at this point in the history
…of the benchmark run

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@7784 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information
vp-of-awesome committed Sep 26, 2008
1 parent 6c6c377 commit db3c2d1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions bench/bench_io_tcpserver.rb
@@ -1,16 +1,18 @@
require 'benchmark'
require 'socket'
iter = 50000
buf_sizes = [ 1024, 2048 ]
buf_sizes = [ 1024, 2048, 4096, 8192 ]
PORT = 54321

serv = TCPServer.new('localhost', PORT)
Thread.new {
loop do
buf = 0.chr * 4096
len = 4096
buf = 0.chr * len
client = serv.accept
while s = client.read(buf.length, buf)
while client.read(len)
end
client.write(0.chr)
client.close
end
}
Expand All @@ -21,7 +23,8 @@
sock = TCPSocket.new('localhost', PORT)
buf = 0.chr * size
iter.times { sock.write buf }
sock.close
sock.close_write
sock.read(1)
end
end
end
Expand Down

0 comments on commit db3c2d1

Please sign in to comment.