Sha256: 98ff080fb4131f06e1a2a74c351e4aa49adb727f763ed6a3e6c213c61f88b005
Contents?: true
Size: 646 Bytes
Versions: 4
Compression:
Stored size: 646 Bytes
Contents
module WBench module Timings class Latency def initialize(browser) @browser = browser end def result Hash[hosts.map { |host| [host.join(":"), latency_for(*host) ] }.sort] end private def latency_for(hostname, port) (::Benchmark.measure { TCPSocket.new(hostname, port) }.real * 1000).to_i rescue SocketError nil end def hosts @hosts ||= JSON.parse(@browser.evaluate_script('WBench.resourceURLs()')).map do |url| u = Addressable::URI.parse(url) [u.host, u.inferred_port] end.compact.uniq end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
wbench-1.1.1 | lib/wbench/timings/latency.rb |
wbench-1.1.0 | lib/wbench/timings/latency.rb |
wbench-1.0.0 | lib/wbench/timings/latency.rb |
wbench-0.4.0 | lib/wbench/timings/latency.rb |