MCPcopy
hub / github.com/grpc/grpc-go / BenchmarkChainStreamInterceptor

Function BenchmarkChainStreamInterceptor

server_test.go:210–235  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

208}
209
210func BenchmarkChainStreamInterceptor(b *testing.B) {
211 for _, n := range []int{1, 3, 5, 10} {
212 n := n
213 b.Run(strconv.Itoa(n), func(b *testing.B) {
214 interceptors := make([]StreamServerInterceptor, 0, n)
215 for i := 0; i < n; i++ {
216 interceptors = append(interceptors, func(
217 srv any, ss ServerStream, _ *StreamServerInfo, handler StreamHandler,
218 ) error {
219 return handler(srv, ss)
220 })
221 }
222
223 s := NewServer(ChainStreamInterceptor(interceptors...))
224 b.ReportAllocs()
225 b.ResetTimer()
226 for i := 0; i < b.N; i++ {
227 if err := s.opts.streamInt(nil, nil, nil, func(any, ServerStream) error {
228 return nil
229 }); err != nil {
230 b.Fatal(err)
231 }
232 }
233 })
234 }
235}

Callers

nothing calls this directly

Calls 3

ChainStreamInterceptorFunction · 0.85
NewServerFunction · 0.70
FatalMethod · 0.65

Tested by

no test coverage detected