Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: minimum dynamic measurement time and more accurate measurements #193

Merged
merged 11 commits into from
May 2, 2024
18 changes: 8 additions & 10 deletions speedtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,20 @@ func main() {
latencies = append(latencies, latency...)
}
}()
ticker := speedtestClient.CallbackDownloadRate(func(downRate float64) {
speedtestClient.SetCallbackDownload(func(downRate float64) {
if lc == 0 {
task.Printf("Download: %.2fMbps (latency: --)", downRate)
task.Printf("Download: %.2fMbps (latency: --)", downRate*8/1000000)
} else {
task.Printf("Download: %.2fMbps (latency: %dms)", downRate, lc/1000000)
task.Printf("Download: %.2fMbps (latency: %dms)", downRate*8/1000000, lc/1000000)
}
})
if *multi {
task.CheckError(server.MultiDownloadTestContext(context.Background(), servers))
} else {
task.CheckError(server.DownloadTest())
}
ticker.Stop()
mean, _, std, minL, maxL := speedtest.StandardDeviation(latencies)
task.Printf("Download: %.2fMbps (used: %.2fMB) (latency: %dms jitter: %dms min: %dms max: %dms)", server.DLSpeed, float64(server.Context.Manager.GetTotalDownload())/1000/1000, mean/1000000, std/1000000, minL/1000000, maxL/1000000)
task.Printf("Download: %.2fMbps (used: %.2fMB) (latency: %dms jitter: %dms min: %dms max: %dms)", server.DLSpeed*8/1000000, float64(server.Context.Manager.GetTotalDownload())/1000/1000, mean/1000000, std/1000000, minL/1000000, maxL/1000000)
task.Complete()
})

Expand All @@ -177,22 +176,21 @@ func main() {
latencies = append(latencies, latency...)
}
}()
ticker := speedtestClient.CallbackUploadRate(func(upRate float64) {
speedtestClient.SetCallbackUpload(func(upRate float64) {
if lc == 0 {
task.Printf("Upload: %.2fMbps (latency: --)", upRate)
task.Printf("Upload: %.2fMbps (latency: --)", upRate*8/1000000)
} else {
task.Printf("Upload: %.2fMbps (latency: %dms)", upRate, lc/1000000)
task.Printf("Upload: %.2fMbps (latency: %dms)", upRate*8/1000000, lc/1000000)
}
})
if *multi {
task.CheckError(server.MultiUploadTestContext(context.Background(), servers))
} else {
task.CheckError(server.UploadTest())
}
ticker.Stop()
quit = true
mean, _, std, minL, maxL := speedtest.StandardDeviation(latencies)
task.Printf("Upload: %.2fMbps (used: %.2fMB) (latency: %dms jitter: %dms min: %dms max: %dms)", server.ULSpeed, float64(server.Context.Manager.GetTotalUpload())/1000/1000, mean/1000000, std/1000000, minL/1000000, maxL/1000000)
task.Printf("Upload: %.2fMbps (used: %.2fMB) (latency: %dms jitter: %dms min: %dms max: %dms)", server.ULSpeed*8/1000000, float64(server.Context.Manager.GetTotalUpload())/1000/1000, mean/1000000, std/1000000, minL/1000000, maxL/1000000)
task.Complete()
})
taskManager.Reset()
Expand Down
Loading
Loading