mirror of https://github.com/liamg/aminal.git
Added options for setting GOMAXPROCS and profiling output.
This commit is contained in:
parent
8a56135a39
commit
54c85c2a65
|
@ -28,6 +28,8 @@ func getConfig() *config.Config {
|
|||
shell := ""
|
||||
debugMode := false
|
||||
slomo := false
|
||||
threads := 4
|
||||
prof := ""
|
||||
|
||||
if flag.Parsed() == false {
|
||||
flag.BoolVar(&showVersion, "version", showVersion, "Output version information")
|
||||
|
@ -35,6 +37,8 @@ func getConfig() *config.Config {
|
|||
flag.StringVar(&shell, "shell", shell, "Specify the shell to use")
|
||||
flag.BoolVar(&debugMode, "debug", debugMode, "Enable debug logging")
|
||||
flag.BoolVar(&slomo, "slomo", slomo, "Render in slow motion (useful for debugging)")
|
||||
flag.IntVar(&threads, "threads", threads, "Number of threads to use")
|
||||
flag.StringVar(&prof, "prof", prof, "Run profiler and dump info to specifed file")
|
||||
|
||||
flag.Parse() // actual parsing and fetching flags from the command line
|
||||
}
|
||||
|
@ -55,6 +59,8 @@ func getConfig() *config.Config {
|
|||
} else {
|
||||
conf = loadConfigFile()
|
||||
}
|
||||
conf.Prof = prof
|
||||
conf.Threads = threads
|
||||
|
||||
// Override values in the configuration file with the values specified in the command line, if any.
|
||||
if actuallyProvidedFlags["shell"] {
|
||||
|
|
|
@ -16,6 +16,8 @@ type Config struct {
|
|||
SearchURL string `toml:"search_url"`
|
||||
MaxLines uint64 `toml:"max_lines"`
|
||||
CopyAndPasteWithMouse bool `toml:"copy_and_paste_with_mouse"`
|
||||
Prof string `toml:"prof"`
|
||||
Threads int `toml:"threads"`
|
||||
}
|
||||
|
||||
type KeyMappingConfig map[string]string
|
||||
|
|
11
main.go
11
main.go
|
@ -8,6 +8,7 @@ import (
|
|||
"github.com/riywo/loginshell"
|
||||
"os"
|
||||
"runtime"
|
||||
"runtime/pprof"
|
||||
)
|
||||
|
||||
type callback func(terminal *terminal.Terminal, g *gui.GUI)
|
||||
|
@ -23,6 +24,16 @@ func main() {
|
|||
func initialize(unitTestfunc callback) {
|
||||
conf := getConfig()
|
||||
logger, err := getLogger(conf)
|
||||
runtime.GOMAXPROCS(conf.Threads)
|
||||
if conf.Prof != "" {
|
||||
f, err := os.Create(conf.Prof)
|
||||
defer f.Close()
|
||||
if err != nil {
|
||||
logger.Fatal(err)
|
||||
}
|
||||
pprof.StartCPUProfile(f)
|
||||
defer pprof.StopCPUProfile()
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to create logger: %s\n", err)
|
||||
os.Exit(1)
|
||||
|
|
Loading…
Reference in New Issue