Skip to content

Commit 19e81e4

Browse files
committed
benchmark
1 parent 4cfcb5f commit 19e81e4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

reader_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -1871,6 +1871,24 @@ func TestReaderClose(t *testing.T) {
18711871
}
18721872
}
18731873

1874+
func BenchmarkReaderClose(b *testing.B) {
1875+
r := NewReader(ReaderConfig{
1876+
Brokers: []string{"localhost:9092"},
1877+
Topic: makeTopic(),
1878+
MaxWait: 2 * time.Second,
1879+
})
1880+
defer r.Close()
1881+
for i := 0; i < b.N; i++ {
1882+
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
1883+
defer cancel()
1884+
1885+
_, err := r.FetchMessage(ctx)
1886+
if err != context.DeadlineExceeded {
1887+
b.Errorf("bad err: %v", err)
1888+
}
1889+
}
1890+
}
1891+
18741892
// writeMessagesForCompactionCheck writes messages with specific writer configuration.
18751893
func writeMessagesForCompactionCheck(t *testing.T, topic string, msgs []Message) {
18761894
t.Helper()

0 commit comments

Comments
 (0)