Class: SpeedtestNet::Latency

Inherits:
Object
  • Object
show all
Defined in:
lib/speedtest_net/latency.rb

Constant Summary collapse

DEFAULT_TEST_LENGTH =
10
DEFAULT_LATENCY =
3600.0

Class Method Summary collapse

Class Method Details

.measure(server) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/speedtest_net/latency.rb', line 13

def measure(server)
  config = Config.fetch
  test_length = test_length(config)
  timeout = config.latency[:timeout]

  latencies = Array.new(test_length) do
    latency_url = latency_url(server)
    measure_latency(latency_url, timeout)
  end
  server.latency = latencies.min
end