go(report): aggregate all table tex files
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2022-07-16 23:30:56 +02:00
parent 496ddc191a
commit 446f63b59e
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
5 changed files with 76 additions and 2 deletions

@ -57,9 +57,9 @@ func DoRandomSearch(wg *sync.WaitGroup, m *sync.Mutex) {
// protect access to shared data.
m.Lock()
report.SavePicsToFile(pLs, "Random Search")
m.Unlock()
stats.SaveTable("Random Search", algoStats)
m.Unlock()
}
// DoStochasticHillClimbing performs a search using the 'Stochastic Hill
@ -104,9 +104,9 @@ func DoStochasticHillClimbing(wg *sync.WaitGroup, m *sync.Mutex) {
// protect access to shared data.
m.Lock()
report.SavePicsToFile(pLs, "Stochastic Hill Climbing")
m.Unlock()
stats.SaveTable("Stochastic Hill CLimbing", algoStats)
m.Unlock()
}
func newValues() *Values {

@ -31,6 +31,7 @@ func main() {
wg.Wait()
report.SaveTexAllPics()
report.SaveTexAllTables()
report.Print()
log.Println("looks like we're done")

53
report/allTables.go Normal file

@ -0,0 +1,53 @@
// Copyright 2022 wanderer <a_mirre at utb dot cz>
// SPDX-License-Identifier: GPL-3.0-or-later
package report
import (
_ "embed"
"log"
"os"
"text/template"
"time"
)
type tableTexFiles struct {
Algo string
FilePaths []string
}
type allTheTables struct {
TexFiles []tableTexFiles
}
var (
allTables = &allTheTables{}
//go:embed alltables.tmpl
tmplAllTablesFile []byte
)
func SaveTexAllTables() {
a := allTables
texAllTablesFile := GetTexDir() + "alltables" + ".tex"
tmplAllTables := template.New("alltables")
tmplAllTables = template.Must(tmplAllTables.Parse(string(tmplAllTablesFile)))
f, err := os.Create(texAllTablesFile)
if err != nil {
log.Println(err)
}
defer f.Close()
err = tmplAllTables.Execute(f, struct {
AllTables allTheTables
Timestamp time.Time
}{
AllTables: *a,
Timestamp: time.Now(),
})
if err != nil {
log.Println(err)
}
}

17
report/alltables.tmpl Normal file

@ -0,0 +1,17 @@
% Code generated by math-optim; DO NOT EDIT.
%
% This file was generated by robots at
% {{ .Timestamp }}
% 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/
\section{Per-algo benchmark comparison statistics}
{{ range $i, $v := .AllTables.TexFiles }}
{{- range $j, $u := $v.FilePaths }}
\include{ {{- $u -}} }
{{- end -}}
{{ end }}
% vim: ft=gotexttmpl.tex ts=2 sts=2 sw=2 bs=2 expandtab

@ -49,6 +49,9 @@ func SaveTableToFile(t Table) {
tmplTable := template.Must(template.ParseFiles(tmplTableFile))
ttf := tableTexFiles{Algo: t.Algo, FilePaths: []string{texTableFile}}
allTables.TexFiles = append(allTables.TexFiles, ttf)
f, err := os.Create(texTableFile)
if err != nil {
log.Println(err)