Sha256: 252af959a84cecf5d03bc5cead1bb720dc1e3f5f80d346f0578167e0b4abccf8
Contents?: true
Size: 1.77 KB
Versions: 2
Compression:
Stored size: 1.77 KB
Contents
#!/usr/bin/env ruby # Example benchmark scripts: # # websocket-bench broadcast ws://127.0.0.1:3000/ --concurrent 10 --sample-size 100 --server-type binary --step-size 1000 --limit-percentile 95 --limit-rtt 250ms --initial-clients 1000 # # websocket-bench broadcast ws://127.0.0.1:3000/ --concurrent 10 --sample-size 100 --step-size 1000 --limit-percentile 95 --limit-rtt 250ms --initial-clients 1000 --server-type json # Dir.chdir(File.expand_path(File.join('..', '..', 'lib'), __FILE__)) require 'bundler/setup' require 'plezi' class ShootoutApp # the default HTTP response def index "This application should be used with the websocket-shootout benchmark utility." end def on_open subscribe channel: "shootout" end # we won't be using AutoDispatch, but directly using the `on_message` callback. def on_message data if data[0] == 'b' # binary publish(channel: "shootout", message: data) data[0] = 'r' write data return end cmd, payload = JSON(data).values_at('type', 'payload') if cmd == 'echo' write({type: 'echo', payload: payload}.to_json) else # data = {type: 'broadcast', payload: payload}.to_json # broadcast :push2client, data publish(channel: "shootout", message: ({type: 'broadcast', payload: payload}.to_json)) write({type: "broadcastResult", payload: payload}.to_json) end rescue puts "Incoming message format error - not JSON?" end end Plezi.route '*', ShootoutApp # # def cycle # puts `websocket-bench broadcast ws://127.0.0.1:3000/ --concurrent 10 --sample-size 100 --server-type binary --step-size 1000 --limit-percentile 95 --limit-rtt 250ms --initial-clients 1000` # sleep(2) # puts `wrk -c4000 -d15 -t12 http://localhost:3000/` # true # end # sleep(10) while cycle
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
plezi-0.15.1 | bin/ws_shootout |
plezi-0.15.0 | bin/ws_shootout |