add profiling support for sdk

This commit is contained in:
arraykeys@gmail.com
2018-12-05 14:52:59 +08:00
parent 4ce5fd463d
commit 0a2ed2e498

View File

@ -483,11 +483,11 @@ func Version() string {
return SDK_VERSION return SDK_VERSION
} }
func StartProfiling(storePath string) { func StartProfiling(storePath string) {
if isProfiling { if !isProfiling {
isProfiling = true
if storePath == "" { if storePath == "" {
storePath = "." storePath = "."
} }
isProfiling = true
cpuProfilingFile, _ = os.Create(filepath.Join(storePath, "cpu.prof")) cpuProfilingFile, _ = os.Create(filepath.Join(storePath, "cpu.prof"))
memProfilingFile, _ = os.Create(filepath.Join(storePath, "memory.prof")) memProfilingFile, _ = os.Create(filepath.Join(storePath, "memory.prof"))
blockProfilingFile, _ = os.Create(filepath.Join(storePath, "block.prof")) blockProfilingFile, _ = os.Create(filepath.Join(storePath, "block.prof"))