Skip to content

Commit

Permalink
feat(benchmark): use humanize to print stats
Browse files Browse the repository at this point in the history
  • Loading branch information
ooesili committed Nov 5, 2024
1 parent acc24c6 commit 04492f2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ require (
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/emicklei/proto v1.10.0 h1:pDGyFRVV5RvV+nkBK9iy3q67FBy9Xa7vwrOTE+g5aGw=
github.com/emicklei/proto v1.10.0/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A=
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
Expand Down
9 changes: 5 additions & 4 deletions internal/impl/pure/processor_benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"sync"
"time"

"github.com/dustin/go-humanize"
"github.com/redpanda-data/benthos/v4/public/service"
)

Expand Down Expand Up @@ -133,13 +134,13 @@ func (b *benchmarkProc) sampleRolling() benchmarkStats {
return s
}

func (b *benchmarkProc) printStats(window string, s benchmarkStats, interval time.Duration) {
func (b *benchmarkProc) printStats(window string, stats benchmarkStats, interval time.Duration) {
secs := interval.Seconds()
b.logger.Infof(
"%s stats: %.2f msgs/sec, %.2f bytes/sec",
"%s stats: %s msg/sec, %s/sec",
window,
s.msgCount/secs,
s.msgBytesCount/secs,
humanize.Ftoa(stats.msgCount/secs),
humanize.Bytes(uint64(stats.msgBytesCount/secs)),
)
}

Expand Down

0 comments on commit 04492f2

Please sign in to comment.