Keith Randall | 50bc3d5 | 2014-12-15 14:39:28 -0800 | [diff] [blame] | 1 | // run |
| 2 | |
| 3 | // Copyright 2014 The Go Authors. All rights reserved. |
| 4 | // Use of this source code is governed by a BSD-style |
| 5 | // license that can be found in the LICENSE file. |
| 6 | |
| 7 | package main |
| 8 | |
| 9 | import ( |
| 10 | "bytes" |
| 11 | "runtime" |
| 12 | "runtime/pprof" |
| 13 | "sync" |
| 14 | ) |
| 15 | |
| 16 | func test() { |
| 17 | var wg sync.WaitGroup |
| 18 | wg.Add(2) |
| 19 | test := func() { |
Keith Randall | fcfbeb3 | 2015-01-07 16:46:29 -0800 | [diff] [blame] | 20 | for i := 0; i < 10; i++ { |
Keith Randall | 50bc3d5 | 2014-12-15 14:39:28 -0800 | [diff] [blame] | 21 | buf := &bytes.Buffer{} |
| 22 | pprof.Lookup("goroutine").WriteTo(buf, 2) |
| 23 | } |
| 24 | wg.Done() |
| 25 | } |
| 26 | |
| 27 | go test() |
| 28 | go test() |
| 29 | wg.Wait() |
| 30 | } |
| 31 | |
| 32 | func main() { |
Keith Randall | fcfbeb3 | 2015-01-07 16:46:29 -0800 | [diff] [blame] | 33 | runtime.GOMAXPROCS(4) |
| 34 | for i := 0; i < 10; i++ { |
Keith Randall | 50bc3d5 | 2014-12-15 14:39:28 -0800 | [diff] [blame] | 35 | test() |
| 36 | } |
| 37 | } |