diff options
Diffstat (limited to 'src/context/benchmark_test.go')
| -rw-r--r-- | src/context/benchmark_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/context/benchmark_test.go b/src/context/benchmark_test.go index 5d56863050..c4c72f00f8 100644 --- a/src/context/benchmark_test.go +++ b/src/context/benchmark_test.go @@ -5,6 +5,7 @@ package context_test import ( + "context" . "context" "fmt" "runtime" @@ -138,3 +139,17 @@ func BenchmarkCheckCanceled(b *testing.B) { } }) } + +func BenchmarkContextCancelDone(b *testing.B) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + select { + case <-ctx.Done(): + default: + } + } + }) +} |
