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

Function makeFuncStream

benchmark/benchmain/main.go:434–464  ·  view source on GitHub ↗
(bf stats.Features)

Source from the content-addressed store, hash-verified

432}
433
434func makeFuncStream(bf stats.Features) (rpcCallFunc, rpcCleanupFunc) {
435 streams, req, cleanup := setupStream(bf, false)
436
437 var preparedMsg [][]*grpc.PreparedMsg
438 if bf.EnablePreloader {
439 preparedMsg = prepareMessages(streams, req)
440 }
441
442 return func(cn, pos int) {
443 reqSizeBytes := bf.ReqSizeBytes
444 respSizeBytes := bf.RespSizeBytes
445 if bf.ReqPayloadCurve != nil {
446 reqSizeBytes = bf.ReqPayloadCurve.ChooseRandom()
447 }
448 if bf.RespPayloadCurve != nil {
449 respSizeBytes = bf.RespPayloadCurve.ChooseRandom()
450 }
451 var req any
452 if bf.EnablePreloader {
453 req = preparedMsg[cn][pos]
454 } else {
455 pl := benchmark.NewPayload(testpb.PayloadType_COMPRESSABLE, reqSizeBytes)
456 req = &testpb.SimpleRequest{
457 ResponseType: pl.Type,
458 ResponseSize: int32(respSizeBytes),
459 Payload: pl,
460 }
461 }
462 streamCaller(streams[cn][pos], req)
463 }, cleanup
464}
465
466func makeFuncUnconstrainedStreamPreloaded(bf stats.Features) (rpcSendFunc, rpcRecvFunc, rpcCleanupFunc) {
467 streams, req, cleanup := setupStream(bf, true)

Callers 1

streamBenchmarkFunction · 0.85

Calls 5

NewPayloadFunction · 0.92
setupStreamFunction · 0.85
prepareMessagesFunction · 0.85
streamCallerFunction · 0.85
ChooseRandomMethod · 0.80

Tested by

no test coverage detected