From e3a091df53d8308b11c7917f6fa2f8d22dc31d10 Mon Sep 17 00:00:00 2001 From: Injun Song Date: Mon, 10 Jul 2023 23:05:38 +0900 Subject: [PATCH] fix(benchmark): make append duration's precision high This change makes the append response time's resolution of the benchmark high. Previously, its decimal representation was discarded. From now, its decimal representation can be shown. --- internal/benchmark/loader.go | 2 +- internal/benchmark/metrics.go | 2 +- internal/benchmark/report.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/benchmark/loader.go b/internal/benchmark/loader.go index 805242903..3df4f2ecc 100644 --- a/internal/benchmark/loader.go +++ b/internal/benchmark/loader.go @@ -145,7 +145,7 @@ func (loader *Loader) makeAppendFunc(ctx context.Context, c varlog.Log, am *Appe recordMetrics := func(dur time.Duration) { am.bytes += int64(loader.BatchSize * loader.MessageSize) am.requests++ - am.durationMS += dur.Milliseconds() + am.durationMS = float64(dur.Nanoseconds()) / float64(time.Millisecond) if loader.metrics.ReportAppendMetrics(*am) { *am = AppendMetrics{} } diff --git a/internal/benchmark/metrics.go b/internal/benchmark/metrics.go index 0ca023778..83edab5d5 100644 --- a/internal/benchmark/metrics.go +++ b/internal/benchmark/metrics.go @@ -38,7 +38,7 @@ type LoaderMetrics struct { type AppendMetrics struct { requests int64 bytes int64 - durationMS int64 + durationMS float64 } type SubscribeMetrics struct { diff --git a/internal/benchmark/report.go b/internal/benchmark/report.go index 1f3bcb938..3f26be041 100644 --- a/internal/benchmark/report.go +++ b/internal/benchmark/report.go @@ -17,7 +17,7 @@ func NewAppendReportFromMetrics(metrics AppendMetrics, interval time.Duration) A bps = float64(metrics.bytes) / itv } if metrics.requests > 0 { - dur = float64(metrics.durationMS / metrics.requests) + dur = metrics.durationMS / float64(metrics.requests) } return AppendReport{ RequestsPerSecond: rps,