add profiling support for sdk
This commit is contained in:
@ -482,15 +482,20 @@ func Stop(serviceID string) {
|
|||||||
func Version() string {
|
func Version() string {
|
||||||
return SDK_VERSION
|
return SDK_VERSION
|
||||||
}
|
}
|
||||||
func StartProfiling() {
|
func StartProfiling(storePath string) {
|
||||||
|
if isProfiling {
|
||||||
|
if storePath == "" {
|
||||||
|
storePath = "."
|
||||||
|
}
|
||||||
isProfiling = true
|
isProfiling = true
|
||||||
cpuProfilingFile, _ = os.Create("cpu.prof")
|
cpuProfilingFile, _ = os.Create(filepath.Join(storePath, "cpu.prof"))
|
||||||
memProfilingFile, _ = os.Create("memory.prof")
|
memProfilingFile, _ = os.Create(filepath.Join(storePath, "memory.prof"))
|
||||||
blockProfilingFile, _ = os.Create("block.prof")
|
blockProfilingFile, _ = os.Create(filepath.Join(storePath, "block.prof"))
|
||||||
goroutineProfilingFile, _ = os.Create("goroutine.prof")
|
goroutineProfilingFile, _ = os.Create(filepath.Join(storePath, "goroutine.prof"))
|
||||||
threadcreateProfilingFile, _ = os.Create("threadcreate.prof")
|
threadcreateProfilingFile, _ = os.Create(filepath.Join(storePath, "threadcreate.prof"))
|
||||||
pprof.StartCPUProfile(cpuProfilingFile)
|
pprof.StartCPUProfile(cpuProfilingFile)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
func StopProfiling() {
|
func StopProfiling() {
|
||||||
if isProfiling {
|
if isProfiling {
|
||||||
isProfiling = false
|
isProfiling = false
|
||||||
|
|||||||
Reference in New Issue
Block a user