1 // Copyright 2011 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.
13 var stop = make(chan bool, 1)
15 func perpetuumMobile() {
23 func TestStopTheWorldDeadlock(t *testing.T) {
25 t.Logf("skipping during short test")
28 maxprocs := runtime.GOMAXPROCS(3)
29 compl := make(chan bool, 2)
31 for i := 0; i != 1000; i += 1 {
37 for i := 0; i != 1000; i += 1 {
46 runtime.GOMAXPROCS(maxprocs)
49 func stackGrowthRecursive(i int) {
51 if i != 0 && pad[0] == 0 {
52 stackGrowthRecursive(i - 1)
56 func BenchmarkStackGrowth(b *testing.B) {
57 const CallsPerSched = 1000
58 procs := runtime.GOMAXPROCS(-1)
59 N := int32(b.N / CallsPerSched)
60 c := make(chan bool, procs)
61 for p := 0; p < procs; p++ {
63 for atomic.AddInt32(&N, -1) >= 0 {
65 for g := 0; g < CallsPerSched; g++ {
66 stackGrowthRecursive(10)
72 for p := 0; p < procs; p++ {
77 func BenchmarkSyscall(b *testing.B) {
78 const CallsPerSched = 1000
79 procs := runtime.GOMAXPROCS(-1)
80 N := int32(b.N / CallsPerSched)
81 c := make(chan bool, procs)
82 for p := 0; p < procs; p++ {
84 for atomic.AddInt32(&N, -1) >= 0 {
86 for g := 0; g < CallsPerSched; g++ {
87 runtime.Entersyscall()
94 for p := 0; p < procs; p++ {
99 func BenchmarkSyscallWork(b *testing.B) {
100 const CallsPerSched = 1000
101 const LocalWork = 100
102 procs := runtime.GOMAXPROCS(-1)
103 N := int32(b.N / CallsPerSched)
104 c := make(chan bool, procs)
105 for p := 0; p < procs; p++ {
108 for atomic.AddInt32(&N, -1) >= 0 {
110 for g := 0; g < CallsPerSched; g++ {
111 runtime.Entersyscall()
112 for i := 0; i < LocalWork; i++ {
116 runtime.Exitsyscall()
122 for p := 0; p < procs; p++ {