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

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

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

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

@ -9,6 +9,7 @@ import (
"sync" "sync"
"time" "time"
"git.dotya.ml/wanderer/math-optim/report"
"git.dotya.ml/wanderer/math-optim/stats" "git.dotya.ml/wanderer/math-optim/stats"
"git.dotya.ml/wanderer/math-optim/util" "git.dotya.ml/wanderer/math-optim/util"
"gonum.org/v1/gonum/floats" "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. defer wg.Done() // does this work with panic in the mix? TODO(me): find out.
start := time.Now() start := time.Now()
picsDir := report.GetPicsDir()
if err := util.CreatePath(picsDir); err != nil {
log.Println(err)
}
pWidth := 13 * vg.Centimeter pWidth := 13 * vg.Centimeter
pHeight := 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) log.Panic(err)
} }
if err := util.CreatePath(picPath); err != nil { filename := picsDir +
log.Println(err)
}
filename := picPath +
fPrefix + "-" + fPrefix + "-" +
util.SanitiseFName(s.Algo) + "-" + util.SanitiseFName(s.Algo) + "-" +
util.SanitiseFName(dim.BenchName) + "-" + util.SanitiseFName(dim.BenchName) + "-" +

@ -12,6 +12,16 @@ import (
"os" "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. // Print prints stats in a report format.
func Print() { func Print() {
fmt.Fprint(os.Stderr, "\n* printing the report...\n\n") fmt.Fprint(os.Stderr, "\n* printing the report...\n\n")