Source File
cpuprof.go
Belonging Package
runtime
package runtime
import (
)
const maxCPUProfStack = 64
type cpuProfile struct {
lock mutex
on bool // profiling is on
log *profBuf // profile events written here
extra [1000]uintptr
numExtra int
lostExtra uint64 // count of frames lost because extra is full
lostAtomic uint64 // count of frames lost because of being in atomic64 on mips/arm; updated racily
}
var cpuprof cpuProfile
if < 0 {
= 0
}
if > 1000000 {
= 1000000
}
lock(&cpuprof.lock)
if > 0 {
if cpuprof.on || cpuprof.log != nil {
print("runtime: cannot set cpu profile rate until previous profile has finished.\n")
unlock(&cpuprof.lock)
return
}
cpuprof.on = true
cpuprof.log = newProfBuf(1, 1<<17, 1<<14)
:= [1]uint64{uint64()}
cpuprof.log.write(nil, nanotime(), [:], nil)
setcpuprofilerate(int32())
} else if cpuprof.on {
setcpuprofilerate(0)
cpuprof.on = false
cpuprof.addExtra()
cpuprof.log.close()
}
unlock(&cpuprof.lock)
}
if .lostExtra > 0 {
:= [1]uint64{.lostExtra}
:= [2]uintptr{
funcPC(_LostExternalCode) + sys.PCQuantum,
funcPC(_ExternalCode) + sys.PCQuantum,
}
.log.write(nil, 0, [:], [:])
.lostExtra = 0
}
if .lostAtomic > 0 {
:= [1]uint64{.lostAtomic}
:= [2]uintptr{
funcPC(_LostSIGPROFDuringAtomic64) + sys.PCQuantum,
funcPC(_System) + sys.PCQuantum,
}
.log.write(nil, 0, [:], [:])
.lostAtomic = 0
}
}
func () int64 {
return tickspersecond()
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |