From 85e5db265a36221585f453578b4984394b4535b5 Mon Sep 17 00:00:00 2001 From: Roberto D'Auria Date: Tue, 6 Feb 2024 12:26:32 +0100 Subject: [PATCH] Fix output --- pkg/client/client.go | 7 +++++-- pkg/client/emitter.go | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/client/client.go b/pkg/client/client.go index f15e525..c4f003a 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -107,6 +107,8 @@ type Throughput1Client struct { // Result contains the aggregate metrics collected during the test. type Result struct { + // Subtest is the subtest this Result refers to. + Subtest spec.SubtestKind // Goodput is the average number of application-level bits per second that // have been transferred so far across all the streams. Goodput float64 @@ -353,7 +355,7 @@ func (c *Throughput1Client) runStream(ctx context.Context, streamID int, mURL *u m.Network.BytesReceived, m.Network.BytesSent)) c.storeMeasurement(streamID, m) if c.started.Load() { - res := c.computeResult() + res := c.computeResult(subtest) c.config.Emitter.OnResult(res) c.lastResultForSubtestMutex.Lock() c.lastResultForSubtest[subtest] = res @@ -393,11 +395,12 @@ func (c *Throughput1Client) applicationBytes() int64 { } // computeResult returns a Result struct with the current state of the measurement. -func (c *Throughput1Client) computeResult() Result { +func (c *Throughput1Client) computeResult(subtest spec.SubtestKind) Result { applicationBytes := c.applicationBytes() elapsed := time.Since(c.sharedStartTime) goodput := float64(applicationBytes) / float64(elapsed.Seconds()) * 8 // bps return Result{ + Subtest: subtest, Elapsed: elapsed, Goodput: goodput, Throughput: 0, // TODO, diff --git a/pkg/client/emitter.go b/pkg/client/emitter.go index 694abf5..c2689cc 100644 --- a/pkg/client/emitter.go +++ b/pkg/client/emitter.go @@ -36,8 +36,8 @@ type HumanReadable struct { // OnResult prints the aggregate result. func (HumanReadable) OnResult(r Result) { - fmt.Printf("Download rate: %f Mb/s, rtt: %.2f, minrtt: %.2f\n", - r.Goodput/1e6, float32(r.RTT)/1000, float32(r.MinRTT)/1000) + fmt.Printf("%s rate: %f Mb/s, rtt: %.2f, minrtt: %.2f\n", + r.Subtest, r.Goodput/1e6, float32(r.RTT)/1000, float32(r.MinRTT)/1000) } // OnStart is called when the stream starts and prints the subtest and server hostname. @@ -71,8 +71,10 @@ func (HumanReadable) OnSummary(results map[spec.SubtestKind]Result) { fmt.Println() fmt.Printf("Test results:\n") for kind, result := range results { - fmt.Printf(" %s rate: %.2f Mb/s, rtt: %.2f ms, minrtt: %.2f ms\n", + fmt.Printf(" %s rate: %.2f Mb/s, rtt: %.2fms, minrtt: %.2fms\n", kind, result.Goodput/1e6, float32(result.RTT)/1000, float32(result.MinRTT)/1000) + fmt.Printf(" streams: %d, duration: %.2fs, cc algo: %s, byte limit: %d bytes\n", + result.Streams, result.Length.Seconds(), result.CongestionControl, result.ByteLimit) } }