From 4ce5fd463da469c9f86d2afd5f0c09575c267a41 Mon Sep 17 00:00:00 2001 From: "arraykeys@gmail.com" Date: Wed, 5 Dec 2018 14:52:00 +0800 Subject: [PATCH] add profiling support for sdk --- sdk/android-ios/sdk.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/sdk/android-ios/sdk.go b/sdk/android-ios/sdk.go index 7ff1e5a..a11a45a 100644 --- a/sdk/android-ios/sdk.go +++ b/sdk/android-ios/sdk.go @@ -482,14 +482,19 @@ func Stop(serviceID string) { func Version() string { return SDK_VERSION } -func StartProfiling() { - isProfiling = true - cpuProfilingFile, _ = os.Create("cpu.prof") - memProfilingFile, _ = os.Create("memory.prof") - blockProfilingFile, _ = os.Create("block.prof") - goroutineProfilingFile, _ = os.Create("goroutine.prof") - threadcreateProfilingFile, _ = os.Create("threadcreate.prof") - pprof.StartCPUProfile(cpuProfilingFile) +func StartProfiling(storePath string) { + if isProfiling { + if storePath == "" { + storePath = "." + } + isProfiling = true + cpuProfilingFile, _ = os.Create(filepath.Join(storePath, "cpu.prof")) + memProfilingFile, _ = os.Create(filepath.Join(storePath, "memory.prof")) + blockProfilingFile, _ = os.Create(filepath.Join(storePath, "block.prof")) + goroutineProfilingFile, _ = os.Create(filepath.Join(storePath, "goroutine.prof")) + threadcreateProfilingFile, _ = os.Create(filepath.Join(storePath, "threadcreate.prof")) + pprof.StartCPUProfile(cpuProfilingFile) + } } func StopProfiling() { if isProfiling {