Obsolete
/
ipcd
Archived
3
0
Fork 0
This repository has been archived on 2024-06-18. You can view files and clone it, but cannot push or open issues/pull-requests.
ipcd/tests/performances/ipc_message_exchange.cr

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