(b *testing.B)
| 59 | } |
| 60 | |
| 61 | func 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 | |
| 76 | func BenchmarkTimerContextErrNoErr(b *testing.B) { |
| 77 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |