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

Function BenchmarkCancelContextChannelGotErr

benchmark/primitives/context_test.go:61–74  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

59}
60
61func BenchmarkCancelContextChannelGotErr(b *testing.B) {
62 ctx, cancel := context.WithCancel(context.Background())
63 cancel()
64 for i := 0; i < b.N; i++ {
65 select {
66 case <-ctx.Done():
67 if err := ctx.Err(); err == nil {
68 b.Fatal("error")
69 }
70 default:
71 b.Fatal("error: !ctx.Done()")
72 }
73 }
74}
75
76func BenchmarkTimerContextErrNoErr(b *testing.B) {
77 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)

Callers

nothing calls this directly

Calls 3

ErrMethod · 0.80
FatalMethod · 0.65
DoneMethod · 0.45

Tested by

no test coverage detected