Skip to content

Commit

Permalink
Merge pull request #66 from showwin/fix_minus_speed
Browse files Browse the repository at this point in the history
fix: speed value can be negative if the bandwidth is large
  • Loading branch information
showwin committed Feb 20, 2022
2 parents db677c8 + f29b701 commit dafff30
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion speedtest/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,17 @@ func (s *Server) downloadTestContext(
return err
}
fTime := time.Now()

// If the bandwidth is too large, the download sometimes finish earlier than the latency.
// In this case, we ignore the the latency that is included server information.
// This is not affected to the final result since this is a warm up test.
timeToSpend := fTime.Sub(sTime.Add(s.Latency)).Seconds()
if timeToSpend < 0 {
timeToSpend = fTime.Sub(sTime).Seconds()
}

// 1.125MB for each request (750 * 750 * 2)
wuSpeed := 1.125 * 8 * 2 / fTime.Sub(sTime.Add(s.Latency)).Seconds()
wuSpeed := 1.125 * 8 * 2 / timeToSpend

// Decide workload by warm up speed
workload := 0
Expand Down

0 comments on commit dafff30

Please sign in to comment.