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

Function runWithConn

benchmark/client/main.go:149–172  ·  view source on GitHub ↗
(cc *grpc.ClientConn, req *testpb.SimpleRequest, warmDeadline, endDeadline time.Time)

Source from the content-addressed store, hash-verified

147}
148
149func runWithConn(cc *grpc.ClientConn, req *testpb.SimpleRequest, warmDeadline, endDeadline time.Time) {
150 for i := 0; i < *numRPC; i++ {
151 wg.Add(1)
152 go func() {
153 defer wg.Done()
154 caller := makeCaller(cc, req)
155 hist := stats.NewHistogram(hopts)
156 for {
157 start := time.Now()
158 if start.After(endDeadline) {
159 mu.Lock()
160 hists = append(hists, hist)
161 mu.Unlock()
162 return
163 }
164 caller()
165 elapsed := time.Since(start)
166 if start.After(warmDeadline) {
167 hist.Add(elapsed.Nanoseconds())
168 }
169 }
170 }()
171 }
172}
173
174func makeCaller(cc *grpc.ClientConn, req *testpb.SimpleRequest) func() {
175 client := testgrpc.NewBenchmarkServiceClient(cc)

Callers 1

mainFunction · 0.85

Calls 8

AddMethod · 0.95
NewHistogramFunction · 0.92
makeCallerFunction · 0.85
NowMethod · 0.80
AddMethod · 0.65
DoneMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected