Skip to content

Commit

Permalink
fix(benchmark): make append duration's precision high
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ijsong committed Jul 12, 2023
1 parent 9913149 commit 448603f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/benchmark/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/benchmark/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type LoaderMetrics struct {
type AppendMetrics struct {
requests int64
bytes int64
durationMS int64
durationMS float64
}

type SubscribeMetrics struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/benchmark/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 448603f

Please sign in to comment.