Compare commits

..

No commits in common. "development" and "feature-ev" have entirely different histories.

11 changed files with 10 additions and 96 deletions

@ -39,7 +39,6 @@ linters:
- misspell
# - prealloc # disable for now as it might be premature optimisation
- revive
- tparallel
- unconvert
- unparam
- unused

13
main.go

@ -3,17 +3,6 @@
package main
import (
"log"
)
func main() {
err := run()
if err != nil {
if err.Error() == "ErrNoAlgoSelected" {
return
}
log.Fatal(err)
}
run()
}

@ -1,46 +0,0 @@
// Copyright 2023 wanderer <a_mirre at utb dot cz>
// SPDX-License-Identifier: GPL-3.0-or-later
package main
import (
"os"
"runtime/pprof"
)
// profileCPU checks whether CPU profiling was requested and if so, enables it.
// NOTE: deferred pprof.StopCPUProfile() needs to be called at the call site of
// this function, otherwise the profiling would end when this function goes out
// of scope.
func profileCPU(prof *string) error {
if *prof != "" {
f, err := os.Create(*prof)
if err != nil {
return err
}
err = pprof.StartCPUProfile(f)
if err != nil {
return err
}
}
return nil
}
// profileMem checks if memory profiling was requested and if so, enables it.
func profileMem(prof *string) error {
if *prof != "" {
f, err := os.Create(*prof)
if err != nil {
return err
}
err = pprof.WriteHeapProfile(f)
if err != nil {
return err
}
}
return nil
}

@ -2,7 +2,7 @@
%
% This file was generated by robots at
% {{ .Timestamp }}
% source: git.dotya.ml/wanderer/math-optim/src/report/allpics.tmpl
% source: git.dotya.ml/wanderer/math-optim/report/allpics.tmpl
% This file is a part of the math-optim project.
% project homepage: https://git.dotya.ml/wanderer/math-optim/

@ -2,7 +2,7 @@
%
% This file was generated by robots at
% {{ .Timestamp }}
% source: git.dotya.ml/wanderer/math-optim/src/report/alltables.tmpl
% source: git.dotya.ml/wanderer/math-optim/report/alltables.tmpl
% This file is a part of the math-optim project.
% project homepage: https://git.dotya.ml/wanderer/math-optim/

@ -2,7 +2,7 @@
%
% This file was generated by robots at
% {{ .Timestamp }}
% source: git.dotya.ml/wanderer/math-optim/src/report/comparisonOfMeans.tmpl
% source: git.dotya.ml/wanderer/math-optim/report/comparisonOfMeans.tmpl
% This file is a part of the math-optim project.
% project homepage: https://git.dotya.ml/wanderer/math-optim/

@ -2,7 +2,7 @@
%
% This file was generated by robots at
% {{ .Timestamp }}
% source: git.dotya.ml/wanderer/math-optim/src/report/pics.tmpl
% source: git.dotya.ml/wanderer/math-optim/report/pics.tmpl
% This file is a part of the math-optim project.
% project homepage: https://git.dotya.ml/wanderer/math-optim/

@ -1,7 +1,7 @@
% Code generated by math-optim; DO NOT EDIT.
% This file was generated by robots at
% {{ .Timestamp }}
% source: git.dotya.ml/wanderer/math-optim/src/report/report.tmpl
% source: git.dotya.ml/wanderer/math-optim/report/report.tmpl
% This file is a part of the math-optim project.
% project homepage: https://git.dotya.ml/wanderer/math-optim/

@ -2,7 +2,7 @@
%
% This file was generated by robots at
% {{ .Timestamp }}
% source: git.dotya.ml/wanderer/math-optim/src/report/table.tmpl
% source: git.dotya.ml/wanderer/math-optim/report/table.tmpl
% This file is a part of the math-optim project.
% project homepage: https://git.dotya.ml/wanderer/math-optim/

25
run.go

@ -4,10 +4,8 @@
package main
import (
"errors"
"flag"
"log"
"runtime/pprof"
"sync"
"git.dotya.ml/wanderer/math-optim/algo"
@ -17,10 +15,6 @@ import (
var version = "development"
var (
// ref: https://go.dev/blog/pprof.
cpuprofile = flag.String("cpuprofile", "", "write cpu profile to this file")
memprofile = flag.String("memprofile", "", "write memory profile to this 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")
@ -35,24 +29,16 @@ var (
c2SOMAT3A = flag.Bool("c2somat3a", false, "run CEC2020 version of the SOMA Team-to-Team Adaptive (T3A)")
)
func run() error {
func run() {
log.Println("starting math-optim version", "'"+version+"'")
flag.Parse()
err := profileCPU(cpuprofile)
if err != nil {
return err
}
// see profile.go on why we're calling this here.
defer pprof.StopCPUProfile()
if *generate {
if !*jDE && !*c2jDE && !*c2SOMAT3A && !*sHC && !*rS {
log.Println("at least one algo needs to be specified, exiting...")
return errors.New("ErrNoAlgoSelected")
return
}
var wg sync.WaitGroup
@ -112,13 +98,6 @@ func run() error {
report.SaveAndPrint(*doPrint)
err = profileMem(memprofile)
if err != nil {
return err
}
log.Println("looks like we're done")
log.Println("run an equivalent of `pdflatex -clean -shell-escape -interaction=nonstopmode ./report.tex` to get a pdf")
return nil
}

@ -23,12 +23,5 @@ func TestRun(t *testing.T) {
t.Errorf("failed to not run jDE: %q", err)
}
err := run()
if err != nil {
if err.Error() == "ErrNoAlgoSelected" {
return
}
t.Error(err)
}
run()
}