aboutsummaryrefslogtreecommitdiff
path: root/src/context/benchmark_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/context/benchmark_test.go')
-rw-r--r--src/context/benchmark_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/context/benchmark_test.go b/src/context/benchmark_test.go
index 144f473a44..d10950d258 100644
--- a/src/context/benchmark_test.go
+++ b/src/context/benchmark_test.go
@@ -188,3 +188,23 @@ func BenchmarkDeepValueSameGoRoutine(b *testing.B) {
})
}
}
+
+func BenchmarkErrOK(b *testing.B) {
+ ctx, cancel := WithCancel(Background())
+ defer cancel()
+ for b.Loop() {
+ if err := ctx.Err(); err != nil {
+ b.Fatalf("ctx.Err() = %v", err)
+ }
+ }
+}
+
+func BenchmarkErrCanceled(b *testing.B) {
+ ctx, cancel := WithCancel(Background())
+ cancel()
+ for b.Loop() {
+ if err := ctx.Err(); err == nil {
+ b.Fatalf("ctx.Err() = %v", err)
+ }
+ }
+}