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

refactor(client): expose single latency measurement #12

Merged
merged 1 commit into from
Jun 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import (
)

type Result struct {
ConnectionEstablishedSeconds float64 `json:"connectionEstablishedSeconds"`
UploadSeconds float64 `json:"uploadSeconds"`
DownloadSeconds float64 `json:"downloadSeconds"`
Latency float64 `json:"latency"`
}

func RunClient(addr string, uploadBytes, downloadBytes uint64) error {
Expand All @@ -35,7 +33,6 @@ func RunClient(addr string, uploadBytes, downloadBytes uint64) error {
if err != nil {
return err
}
connectionEstablishmentTook := time.Since(start)
str, err := conn.OpenStream()
if err != nil {
return err
Expand All @@ -47,9 +44,7 @@ func RunClient(addr string, uploadBytes, downloadBytes uint64) error {
log.Printf("uploaded %s: %.2fs (%s/s)", formatBytes(uploadBytes), uploadTook.Seconds(), formatBytes(bandwidth(uploadBytes, uploadTook)))
log.Printf("downloaded %s: %.2fs (%s/s)", formatBytes(downloadBytes), downloadTook.Seconds(), formatBytes(bandwidth(downloadBytes, downloadTook)))
json, err := json.Marshal(Result{
ConnectionEstablishedSeconds: connectionEstablishmentTook.Seconds(),
UploadSeconds: uploadTook.Seconds(),
DownloadSeconds: downloadTook.Seconds(),
Latency: time.Since(start).Seconds(),
})
if err != nil {
return err
Expand Down