diff --git a/run.go b/run.go index d9d15d0..f0dea37 100644 --- a/run.go +++ b/run.go @@ -6,6 +6,8 @@ package main import ( "flag" "log" + "os" + "runtime/pprof" "sync" "git.dotya.ml/wanderer/math-optim/algo" @@ -15,6 +17,8 @@ import ( var version = "development" var ( + cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file") + doPrint = flag.Bool("printreport", true, "print report.tex to console") generate = flag.Bool("generate", true, "run algos and generate plot pics/statistical tables (anew)") rS = flag.Bool("randomsearch", false, "run Random Search algorithm") @@ -34,6 +38,20 @@ func run() { flag.Parse() + if *cpuprofile != "" { + f, err := os.Create(*cpuprofile) + if err != nil { + log.Fatal(err) + } + + err = pprof.StartCPUProfile(f) + if err != nil { + log.Fatal(err) + } + + defer pprof.StopCPUProfile() + } + if *generate { if !*jDE && !*c2jDE && !*c2SOMAT3A && !*sHC && !*rS { log.Println("at least one algo needs to be specified, exiting...")