Skip to content

Commit

Permalink
benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
zekth committed Nov 14, 2024
1 parent 4cfcb5f commit 19e81e4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1871,6 +1871,24 @@ func TestReaderClose(t *testing.T) {
}
}

func BenchmarkReaderClose(b *testing.B) {
r := NewReader(ReaderConfig{
Brokers: []string{"localhost:9092"},
Topic: makeTopic(),
MaxWait: 2 * time.Second,
})
defer r.Close()
for i := 0; i < b.N; i++ {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()

_, err := r.FetchMessage(ctx)
if err != context.DeadlineExceeded {
b.Errorf("bad err: %v", err)
}
}
}

// writeMessagesForCompactionCheck writes messages with specific writer configuration.
func writeMessagesForCompactionCheck(t *testing.T, topic string, msgs []Message) {
t.Helper()
Expand Down

0 comments on commit 19e81e4

Please sign in to comment.