Import/Export final touches

This commit is contained in:
Michal Horejsek
2020-08-12 13:56:49 +02:00
parent 4f0af0fb02
commit 658ead9fb3
82 changed files with 451 additions and 450 deletions

View File

@ -24,12 +24,23 @@ import (
"runtime/pprof"
)
// StartCPUProfile starts CPU pprof.
func StartCPUProfile() {
f, err := os.Create("./cpu.pprof")
if err != nil {
log.Fatal("Could not create CPU profile: ", err)
}
if err := pprof.StartCPUProfile(f); err != nil {
log.Fatal("Could not start CPU profile: ", err)
}
}
// MakeMemoryProfile generates memory pprof.
func MakeMemoryProfile() {
name := "./mem.pprof"
f, err := os.Create(name)
if err != nil {
log.Error("Could not create memory profile: ", err)
log.Fatal("Could not create memory profile: ", err)
}
if abs, err := filepath.Abs(name); err == nil {
name = abs
@ -37,7 +48,7 @@ func MakeMemoryProfile() {
log.Info("Writing memory profile to ", name)
runtime.GC() // get up-to-date statistics
if err := pprof.WriteHeapProfile(f); err != nil {
log.Error("Could not write memory profile: ", err)
log.Fatal("Could not write memory profile: ", err)
}
_ = f.Close()
}

View File

@ -17,7 +17,7 @@
package cmd
import "github.com/ProtonMail/proton-bridge/pkg/updates"
import "github.com/ProtonMail/proton-bridge/internal/updates"
// GenerateVersionFiles writes a JSON file with details about current build.
// Those files are used for upgrading the app.