mirror of
https://github.com/golang/go
synced 2024-11-12 09:50:21 -07:00
38 lines
541 B
Go
38 lines
541 B
Go
|
// run
|
||
|
|
||
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||
|
// Use of this source code is governed by a BSD-style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
|
package main
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"runtime"
|
||
|
"runtime/pprof"
|
||
|
"sync"
|
||
|
)
|
||
|
|
||
|
func test() {
|
||
|
var wg sync.WaitGroup
|
||
|
wg.Add(2)
|
||
|
test := func() {
|
||
|
for i := 0; i < 100; i++ {
|
||
|
buf := &bytes.Buffer{}
|
||
|
pprof.Lookup("goroutine").WriteTo(buf, 2)
|
||
|
}
|
||
|
wg.Done()
|
||
|
}
|
||
|
|
||
|
go test()
|
||
|
go test()
|
||
|
wg.Wait()
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
runtime.GOMAXPROCS(2)
|
||
|
for i := 0; i < 100; i++ {
|
||
|
test()
|
||
|
}
|
||
|
}
|