diff --git a/reader_test.go b/reader_test.go index d777bc4a..ff59e9b3 100644 --- a/reader_test.go +++ b/reader_test.go @@ -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()