go: standardise output dirs for reporting material
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2022-07-12 16:56:49 +02:00
parent 65b1ce02df
commit 7b22723cb0
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
5 changed files with 29 additions and 9 deletions

2
.gitignore vendored
View File

@ -4,6 +4,8 @@
result
result-*
math-optim
# output dir for generated plot pics/tex files
out
.vimrc

View File

@ -14,8 +14,6 @@
// methods over it.
type Values []float64
var picPath = "res/"
var plotWg sync.WaitGroup
// DoRandomSearch executes a search using the 'Random search' method.

View File

@ -7,6 +7,8 @@
"os"
"sync"
"testing"
"git.dotya.ml/wanderer/math-optim/report"
)
var wg sync.WaitGroup
@ -18,7 +20,9 @@ func TestDoRandomSearchExec(t *testing.T) {
wg.Wait()
if err := os.RemoveAll(picPath); err != nil {
picsDir := report.GetPicsDir()
if err := os.RemoveAll(picsDir); err != nil {
t.Error(err)
}
}
@ -30,7 +34,9 @@ func TestDoSHCExec(t *testing.T) {
wg.Wait()
if err := os.RemoveAll(picPath); err != nil {
picsDir := report.GetPicsDir()
if err := os.RemoveAll(picsDir); err != nil {
t.Error(err)
}
}

View File

@ -9,6 +9,7 @@
"sync"
"time"
"git.dotya.ml/wanderer/math-optim/report"
"git.dotya.ml/wanderer/math-optim/stats"
"git.dotya.ml/wanderer/math-optim/util"
"gonum.org/v1/gonum/floats"
@ -26,6 +27,13 @@ func plotAllDims(algoStats []stats.Stats, fPrefix, fExt string, wg *sync.WaitGro
defer wg.Done() // does this work with panic in the mix? TODO(me): find out.
start := time.Now()
picsDir := report.GetPicsDir()
if err := util.CreatePath(picsDir); err != nil {
log.Println(err)
}
pWidth := 13 * vg.Centimeter
pHeight := 13 * vg.Centimeter
@ -89,11 +97,7 @@ func plotAllDims(algoStats []stats.Stats, fPrefix, fExt string, wg *sync.WaitGro
log.Panic(err)
}
if err := util.CreatePath(picPath); err != nil {
log.Println(err)
}
filename := picPath +
filename := picsDir +
fPrefix + "-" +
util.SanitiseFName(s.Algo) + "-" +
util.SanitiseFName(dim.BenchName) + "-" +

View File

@ -12,6 +12,16 @@
"os"
)
const (
outPrefix = "out/"
picsDir = "pics/"
)
// GetPicsDirPrefix returns the path to the folder meant for plot pics.
func GetPicsDir() string {
return outPrefix + picsDir
}
// Print prints stats in a report format.
func Print() {
fmt.Fprint(os.Stderr, "\n* printing the report...\n\n")