28 lines
573 B
Crystal
28 lines
573 B
Crystal
|
require "benchmark"
|
||
|
require "ipc"
|
||
|
require "../test-ws"
|
||
|
|
||
|
ws_uri = "ws://localhost:1234/pong"
|
||
|
ws_uri_json = "ws://localhost:1234/pong.JSON"
|
||
|
ws_pong = TestWS.new ws_uri
|
||
|
ws_pong_json = TestWS.new ws_uri_json
|
||
|
|
||
|
pong = IPC::Connection.new "pong"
|
||
|
|
||
|
Benchmark.ips do |bm|
|
||
|
bm.report("direct: round trip time") do
|
||
|
pong.send 42, "coucou"
|
||
|
m = pong.read
|
||
|
end
|
||
|
|
||
|
bm.report("web sockets: round trip time") do
|
||
|
ws_pong.send 42, "coucou"
|
||
|
m = ws_pong.read
|
||
|
end
|
||
|
|
||
|
bm.report("web sockets + json: round trip time") do
|
||
|
ws_pong_json.send 42, "coucou"
|
||
|
m = ws_pong_json.read
|
||
|
end
|
||
|
end
|