MCPcopy
hub / github.com/segmentio/kafka-go / BenchmarkFetchResponse

Function BenchmarkFetchResponse

protocol/fetch/fetch_test.go:93–147  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

91}
92
93func BenchmarkFetchResponse(b *testing.B) {
94 t0 := time.Now().Truncate(time.Millisecond)
95 t1 := t0.Add(1 * time.Millisecond)
96 t2 := t0.Add(2 * time.Millisecond)
97
98 prototest.BenchmarkResponse(b, v0, &fetch.Response{
99 Topics: []fetch.ResponseTopic{
100 {
101 Topic: "topic-1",
102 Partitions: []fetch.ResponsePartition{
103 {
104 Partition: 1,
105 HighWatermark: 1000,
106 RecordSet: protocol.RecordSet{
107 Version: 1,
108 Records: protocol.NewRecordReader(
109 protocol.Record{Offset: 0, Time: t0, Key: nil, Value: prototest.String("msg-0")},
110 protocol.Record{Offset: 1, Time: t1, Key: nil, Value: prototest.String("msg-1")},
111 protocol.Record{Offset: 2, Time: t2, Key: prototest.Bytes([]byte{1}), Value: prototest.String("msg-2")},
112 ),
113 },
114 },
115 },
116 },
117 },
118 })
119
120 headers := []protocol.Header{
121 {Key: "key-1", Value: []byte("value-1")},
122 {Key: "key-2", Value: []byte("value-2")},
123 {Key: "key-3", Value: []byte("value-3")},
124 }
125
126 prototest.BenchmarkResponse(b, v11, &fetch.Response{
127 Topics: []fetch.ResponseTopic{
128 {
129 Topic: "topic-1",
130 Partitions: []fetch.ResponsePartition{
131 {
132 Partition: 1,
133 HighWatermark: 1000,
134 RecordSet: protocol.RecordSet{
135 Version: 2,
136 Records: protocol.NewRecordReader(
137 protocol.Record{Offset: 0, Time: t0, Key: nil, Value: prototest.String("msg-0"), Headers: headers},
138 protocol.Record{Offset: 1, Time: t1, Key: nil, Value: prototest.String("msg-1")},
139 protocol.Record{Offset: 2, Time: t2, Key: prototest.Bytes([]byte{1}), Value: prototest.String("msg-2")},
140 ),
141 },
142 },
143 },
144 },
145 },
146 })
147}

Callers

nothing calls this directly

Calls 5

BenchmarkResponseFunction · 0.92
NewRecordReaderFunction · 0.92
StringFunction · 0.92
BytesFunction · 0.92
TruncateMethod · 0.45

Tested by

no test coverage detected