Esempio n. 1
0
func CgoCCodeSIGPROF() {
	c := make(chan bool)
	go func() {
		for {
			<-c
			start := time.Now()
			for i := 0; i < 1e7; i++ {
				if i%1000 == 0 {
					if time.Since(start) > time.Second {
						break
					}
				}
				C.GoNop()
			}
			c <- true
		}
	}()

	var buf bytes.Buffer
	pprof.StartCPUProfile(&buf)
	c <- true
	<-c
	pprof.StopCPUProfile()

	fmt.Println("OK")
}
Esempio n. 2
0
func CgoCCodeSIGPROF() {
	c := make(chan bool)
	go func() {
		for {
			<-c
			for i := 0; i < 1e7; i++ {
				C.GoNop()
			}
			c <- true
		}
	}()

	var buf bytes.Buffer
	pprof.StartCPUProfile(&buf)
	c <- true
	<-c
	pprof.StopCPUProfile()

	fmt.Println("OK")
}