[ARM] Fix typo in comment in arm_expand_prologue
[official-gcc.git] / libgo / go / context / benchmark_test.go
blobb79232704eb7d14257f69e4bae80dc3b88f30439
1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 package context_test
7 import (
8 . "context"
9 "fmt"
10 "testing"
13 func BenchmarkContextCancelTree(b *testing.B) {
14 depths := []int{1, 10, 100, 1000}
15 for _, d := range depths {
16 b.Run(fmt.Sprintf("depth=%d", d), func(b *testing.B) {
17 b.Run("Root=Background", func(b *testing.B) {
18 for i := 0; i < b.N; i++ {
19 buildContextTree(Background(), d)
22 b.Run("Root=OpenCanceler", func(b *testing.B) {
23 for i := 0; i < b.N; i++ {
24 ctx, cancel := WithCancel(Background())
25 buildContextTree(ctx, d)
26 cancel()
29 b.Run("Root=ClosedCanceler", func(b *testing.B) {
30 for i := 0; i < b.N; i++ {
31 ctx, cancel := WithCancel(Background())
32 cancel()
33 buildContextTree(ctx, d)
40 func buildContextTree(root Context, depth int) {
41 for d := 0; d < depth; d++ {
42 root, _ = WithCancel(root)