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 /* These benchmarks are meaningless for gccgo.
79 func BenchmarkSyscall(b *testing.B) {
80 const CallsPerSched = 1000
81 procs := runtime.GOMAXPROCS(-1)
82 N := int32(b.N / CallsPerSched)
83 c := make(chan bool, procs)
84 for p := 0; p < procs; p++ {
86 for atomic.AddInt32(&N, -1) >= 0 {
88 for g := 0; g < CallsPerSched; g++ {
89 runtime.Entersyscall()
96 for p := 0; p < procs; p++ {
101 func BenchmarkSyscallWork(b *testing.B) {
102 const CallsPerSched = 1000
103 const LocalWork = 100
104 procs := runtime.GOMAXPROCS(-1)
105 N := int32(b.N / CallsPerSched)
106 c := make(chan bool, procs)
107 for p := 0; p < procs; p++ {
110 for atomic.AddInt32(&N, -1) >= 0 {
112 for g := 0; g < CallsPerSched; g++ {
113 runtime.Entersyscall()
114 for i := 0; i < LocalWork; i++ {
118 runtime.Exitsyscall()
124 for p := 0; p < procs; p++ {