-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapp.go
42 lines (33 loc) · 746 Bytes
/
app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
_ "embed"
"flag"
"os"
"github.com/pkg/profile"
"github.com/ventsislav-georgiev/prosper/pkg/core"
)
//go:embed Icon.png
var icon []byte
func main() {
if prof := profileIfRequested(); prof != nil {
defer prof()
}
core.Run(icon)
}
func profileIfRequested() func() {
prof := flag.String("profile", "", "enable profiling (cpu, mem, trace)")
flag.CommandLine.Parse(os.Args[1:])
var profileFunc func(p *profile.Profile) = nil
switch *prof {
case "cpu":
profileFunc = profile.CPUProfile
case "mem":
profileFunc = profile.MemProfileRate(1)
case "trace":
profileFunc = profile.TraceProfile
}
if profileFunc == nil {
return nil
}
return profile.Start(profileFunc, profile.ProfilePath(".")).Stop
}