Skip to content

Commit

Permalink
Added more metrics to be reported
Browse files Browse the repository at this point in the history
  • Loading branch information
sbuliarca committed Apr 11, 2024
1 parent 46a6744 commit 1cb32cc
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func BenchmarkPollRecords(b *testing.B) {
kgo.BlockRebalanceOnPoll(),
// use 10MB
//kgo.FetchMaxPartitionBytes(10*1024*1024),
kgo.WithHooks(&recordBatchReadHook{b: b}),
)

require.NoError(b, err)
Expand All @@ -68,6 +69,16 @@ func BenchmarkPollRecords(b *testing.B) {
}
}

type recordBatchReadHook struct {
b *testing.B
}

func (h *recordBatchReadHook) OnFetchBatchRead(meta kgo.BrokerMetadata, topic string, partition int32, metrics kgo.FetchBatchMetrics) {
h.b.ReportMetric(float64(metrics.CompressedBytes/h.b.N), "compressedbytes/op")
h.b.ReportMetric(float64(metrics.UncompressedBytes/h.b.N), "uncompressedbytes/op")
h.b.ReportMetric(float64(metrics.NumRecords), "recs/op")
}

func populateTopic(ctx context.Context, t *testing.B, broker string, topicName string) error {
t.Log("Start topic population")
producer, err := kgo.NewClient(
Expand Down
62 changes: 31 additions & 31 deletions examples/bench/bench-fetch-max-partition-bytes/testrun_normal.txt
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
goos: darwin
goarch: arm64
pkg: github.com/utilitywarehouse/franz-go/examples/bench/bench-fetch-max-partition-bytes
BenchmarkPollRecords 1 3398178250 ns/op 132786712 B/op 13763 allocs/op
BenchmarkPollRecords 1 3380654666 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 132888208 B/op 13815 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:73: Start topic population
BenchmarkPollRecords 1 3435248375 ns/op 132792696 B/op 13748 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3421492833 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 132877696 B/op 13798 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:73: Start topic population
BenchmarkPollRecords 1 3403719666 ns/op 132784440 B/op 13747 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3381904750 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 132877696 B/op 13798 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:73: Start topic population
BenchmarkPollRecords 1 3412771375 ns/op 132784440 B/op 13747 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3498154791 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 132877696 B/op 13798 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:73: Start topic population
BenchmarkPollRecords 1 3359152166 ns/op 132784440 B/op 13747 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3427531208 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 132877696 B/op 13798 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:73: Start topic population
BenchmarkPollRecords 1 3325048167 ns/op 132784440 B/op 13747 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3383784291 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 132877760 B/op 13799 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:73: Start topic population
BenchmarkPollRecords 1 3385772083 ns/op 132784440 B/op 13747 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3460221375 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 132877696 B/op 13798 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:73: Start topic population
BenchmarkPollRecords 1 3395793292 ns/op 132792632 B/op 13747 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3356974916 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 132877744 B/op 13799 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:73: Start topic population
BenchmarkPollRecords 1 3347914292 ns/op 132784440 B/op 13747 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3472819708 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 132877696 B/op 13798 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:73: Start topic population
BenchmarkPollRecords 1 3444155708 ns/op 132784832 B/op 13749 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3478237125 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 132877744 B/op 13799 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:73: Start topic population
BenchmarkPollRecords 1 3378210667 ns/op 132784440 B/op 13747 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3466253084 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 132877696 B/op 13798 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:73: Start topic population
BenchmarkPollRecords 1 3361311416 ns/op 132784440 B/op 13747 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3332905542 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 132877696 B/op 13798 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:73: Start topic population
BenchmarkPollRecords 1 3389551542 ns/op 132784440 B/op 13747 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3371719375 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 132877696 B/op 13798 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:73: Start topic population
BenchmarkPollRecords 1 3451477334 ns/op 132784504 B/op 13748 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3406518625 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 132877696 B/op 13798 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:73: Start topic population
BenchmarkPollRecords 1 3420341917 ns/op 132792632 B/op 13747 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3376844791 ns/op 59721 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 136133760 B/op 14098 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:73: Start topic population
client_benchmark_test.go:83: Start topic population
PASS
ok github.com/utilitywarehouse/franz-go/examples/bench/bench-fetch-max-partition-bytes 141.652s
ok github.com/utilitywarehouse/franz-go/examples/bench/bench-fetch-max-partition-bytes 141.396s
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
goos: darwin
goarch: arm64
pkg: github.com/utilitywarehouse/franz-go/examples/bench/bench-fetch-max-partition-bytes
BenchmarkPollRecords 1 3829666416 ns/op 655719896 B/op 61927 allocs/op
BenchmarkPollRecords 1 3703996084 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 655723216 B/op 61981 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:72: Start topic population
BenchmarkPollRecords 1 3738498583 ns/op 655709560 B/op 61912 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3600582375 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 655721024 B/op 61965 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:72: Start topic population
BenchmarkPollRecords 1 3645801375 ns/op 655717752 B/op 61912 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3705450875 ns/op 59721 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 655712832 B/op 61965 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:72: Start topic population
BenchmarkPollRecords 1 3726165833 ns/op 655717752 B/op 61912 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3627957166 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 655721024 B/op 61965 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:72: Start topic population
BenchmarkPollRecords 1 3678846000 ns/op 655717752 B/op 61912 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3666480541 ns/op 59721 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 655721024 B/op 61965 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:72: Start topic population
BenchmarkPollRecords 1 3667193375 ns/op 655717760 B/op 61913 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3702227417 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 655721024 B/op 61965 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:72: Start topic population
BenchmarkPollRecords 1 3730089834 ns/op 655717752 B/op 61912 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3677487208 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 655721032 B/op 61966 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:72: Start topic population
BenchmarkPollRecords 1 3658629292 ns/op 655717760 B/op 61913 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3608964833 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 655721120 B/op 61967 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:72: Start topic population
BenchmarkPollRecords 1 3697711792 ns/op 655717752 B/op 61912 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3761873958 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 655712832 B/op 61965 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:72: Start topic population
BenchmarkPollRecords 1 4036467625 ns/op 655725088 B/op 62040 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3654043250 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 655721024 B/op 61965 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:72: Start topic population
BenchmarkPollRecords 1 3633774709 ns/op 655717944 B/op 61915 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3651506333 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 655721032 B/op 61966 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:72: Start topic population
BenchmarkPollRecords 1 3737647833 ns/op 655717752 B/op 61912 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3652002958 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 655721024 B/op 61965 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:72: Start topic population
BenchmarkPollRecords 1 3755905375 ns/op 655717824 B/op 61914 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3609690000 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 655721464 B/op 61969 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:72: Start topic population
BenchmarkPollRecords 1 3632494417 ns/op 655717912 B/op 61914 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3685752542 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 655712832 B/op 61965 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:72: Start topic population
BenchmarkPollRecords 1 3633394459 ns/op 655709560 B/op 61912 allocs/op
client_benchmark_test.go:83: Start topic population
BenchmarkPollRecords 1 3820594291 ns/op 59720 compressedbytes/op 97.00 recs/op 994865 uncompressedbytes/op 655721024 B/op 61965 allocs/op
--- BENCH: BenchmarkPollRecords
client_benchmark_test.go:72: Start topic population
client_benchmark_test.go:83: Start topic population
PASS
ok github.com/utilitywarehouse/franz-go/examples/bench/bench-fetch-max-partition-bytes 150.416s
ok github.com/utilitywarehouse/franz-go/examples/bench/bench-fetch-max-partition-bytes 140.556s

0 comments on commit 1cb32cc

Please sign in to comment.