(b *testing.B)
| 27 | const defaultTestTimeout = 10 * time.Second |
| 28 | |
| 29 | func BenchmarkCancelContextErrNoErr(b *testing.B) { |
| 30 | ctx, cancel := context.WithCancel(context.Background()) |
| 31 | for i := 0; i < b.N; i++ { |
| 32 | if err := ctx.Err(); err != nil { |
| 33 | b.Fatal("error") |
| 34 | } |
| 35 | } |
| 36 | cancel() |
| 37 | } |
| 38 | |
| 39 | func BenchmarkCancelContextErrGotErr(b *testing.B) { |
| 40 | ctx, cancel := context.WithCancel(context.Background()) |