Skip to content

Commit

Permalink
Latency test is not ping time for the purposes of display
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonjchen committed Nov 15, 2015
1 parent a1a3e10 commit 5ee2c2a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/speedtest.rs
Expand Up @@ -308,9 +308,12 @@ pub fn get_best_server_based_on_latency(servers: &[SpeedTestServer])
info!("Sampled {} ms", latency_measurement.num_milliseconds());
latency_measurements.push(latency_measurement);
}
// Divide by the double to get the non-RTT time but the trip time.
// NOT PING or RTT
// https://github.com/sivel/speedtest-cli/pull/199
let latency = latency_measurements.iter().fold(Duration::zero(), |a, &i| a + i) /
latency_measurements.iter().count() as i32;
info!("Averaged to {} ms", latency.num_milliseconds());
(latency_measurements.iter().count() as i32) * 2;
info!("Trip calculated to {} ms", latency.num_milliseconds());

if latency < fastest_latency {
fastest_server = Some(server);
Expand Down

0 comments on commit 5ee2c2a

Please sign in to comment.