I tested the performance of GServer by implementing the most basic server and checked how many requests per second it could handle. The result was 81. This is very slow compared to the 9900 requests per second that my most basic TCPSocket server can handle. Am I doing something wrong or is GServer really this slow?
Client
require 'socket'
tStart = Time.now
u = 0
while Time.now - tStart<5
socket = TCPSocket.open('localhost', 1234)
socket.puts 'a'
socket.gets
socket.close
u += 1
end
puts u.to_s
GServer implementation:
require 'gserver'
class JServer < GServer
def initialize(args)
super(args)
end
def serve( io )
io.gets
io.puts( 'a' )
end
end
server = JServer.new(1234)
server.start
loop { break if server.stopped? }
TCPSocket server impl:
require 'socket'
server = TCPServer.open(1234)
loop {
client = server.accept
puts client.gets
client.puts( 'a' )
client.close
}