Remove unused `helpers` package with single subpackage.
This commit is contained in:
parent
d58a06c323
commit
2d55ed23af
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/status-im/status-go/geth/common"
|
||||
"github.com/status-im/status-go/geth/log"
|
||||
"github.com/status-im/status-go/geth/params"
|
||||
"github.com/status-im/status-go/helpers/profiling"
|
||||
"github.com/status-im/status-go/profiling"
|
||||
"gopkg.in/go-playground/validator.v9"
|
||||
)
|
||||
|
||||
|
|
|
@ -3,21 +3,13 @@ package profiling
|
|||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"runtime/pprof"
|
||||
)
|
||||
|
||||
const (
|
||||
// CPUFilename is a filename in which the CPU profiling is stored.
|
||||
CPUFilename = "status_cpu.prof"
|
||||
// MemFilename is a filename in which the memory profiling is stored.
|
||||
MemFilename = "status_mem.prof"
|
||||
)
|
||||
// CPUFilename is a filename in which the CPU profiling is stored.
|
||||
const CPUFilename = "status_cpu.prof"
|
||||
|
||||
var (
|
||||
cpuFile *os.File
|
||||
memFile *os.File
|
||||
)
|
||||
var cpuFile *os.File
|
||||
|
||||
// StartCPUProfile enables CPU profiling for the current process. While profiling,
|
||||
// the profile will be buffered and written to the file in folder dataDir.
|
||||
|
@ -41,17 +33,3 @@ func StopCPUProfile() error {
|
|||
pprof.StopCPUProfile()
|
||||
return cpuFile.Close()
|
||||
}
|
||||
|
||||
// WriteHeapFile writes heap memory to the file.
|
||||
func WriteHeapFile(dataDir string) error {
|
||||
if memFile == nil {
|
||||
var err error
|
||||
memFile, err = os.Create(filepath.Join(dataDir, MemFilename))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer memFile.Close()
|
||||
}
|
||||
runtime.GC()
|
||||
return pprof.WriteHeapProfile(memFile)
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package profiling
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"runtime/pprof"
|
||||
)
|
||||
|
||||
// MemFilename is a filename in which the memory profiling is stored.
|
||||
const MemFilename = "status_mem.prof"
|
||||
|
||||
var memFile *os.File
|
||||
|
||||
// WriteHeapFile writes heap memory to the file.
|
||||
func WriteHeapFile(dataDir string) error {
|
||||
var err error
|
||||
|
||||
if memFile == nil {
|
||||
memFile, err = os.Create(filepath.Join(dataDir, MemFilename))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer memFile.Close() //nolint: errcheck
|
||||
}
|
||||
runtime.GC()
|
||||
err = pprof.WriteHeapProfile(memFile)
|
||||
|
||||
return err
|
||||
}
|
Loading…
Reference in New Issue