summaryrefslogtreecommitdiff
path: root/libgo/go/runtime/proc_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/runtime/proc_test.go')
-rw-r--r--libgo/go/runtime/proc_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/libgo/go/runtime/proc_test.go b/libgo/go/runtime/proc_test.go
index 32111080a54..1d51c5271e3 100644
--- a/libgo/go/runtime/proc_test.go
+++ b/libgo/go/runtime/proc_test.go
@@ -123,3 +123,29 @@ func BenchmarkSyscallWork(b *testing.B) {
<-c
}
}
+
+func BenchmarkCreateGoroutines(b *testing.B) {
+ benchmarkCreateGoroutines(b, 1)
+}
+
+func BenchmarkCreateGoroutinesParallel(b *testing.B) {
+ benchmarkCreateGoroutines(b, runtime.GOMAXPROCS(-1))
+}
+
+func benchmarkCreateGoroutines(b *testing.B, procs int) {
+ c := make(chan bool)
+ var f func(n int)
+ f = func(n int) {
+ if n == 0 {
+ c <- true
+ return
+ }
+ go f(n - 1)
+ }
+ for i := 0; i < procs; i++ {
+ go f(b.N / procs)
+ }
+ for i := 0; i < procs; i++ {
+ <-c
+ }
+}