go(report): aggregate all table tex files
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
496ddc191a
commit
446f63b59e
@ -57,9 +57,9 @@ func DoRandomSearch(wg *sync.WaitGroup, m *sync.Mutex) {
|
|||||||
// protect access to shared data.
|
// protect access to shared data.
|
||||||
m.Lock()
|
m.Lock()
|
||||||
report.SavePicsToFile(pLs, "Random Search")
|
report.SavePicsToFile(pLs, "Random Search")
|
||||||
m.Unlock()
|
|
||||||
|
|
||||||
stats.SaveTable("Random Search", algoStats)
|
stats.SaveTable("Random Search", algoStats)
|
||||||
|
m.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// DoStochasticHillClimbing performs a search using the 'Stochastic Hill
|
// 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.
|
// protect access to shared data.
|
||||||
m.Lock()
|
m.Lock()
|
||||||
report.SavePicsToFile(pLs, "Stochastic Hill Climbing")
|
report.SavePicsToFile(pLs, "Stochastic Hill Climbing")
|
||||||
m.Unlock()
|
|
||||||
|
|
||||||
stats.SaveTable("Stochastic Hill CLimbing", algoStats)
|
stats.SaveTable("Stochastic Hill CLimbing", algoStats)
|
||||||
|
m.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func newValues() *Values {
|
func newValues() *Values {
|
||||||
|
1
main.go
1
main.go
@ -31,6 +31,7 @@ func main() {
|
|||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
report.SaveTexAllPics()
|
report.SaveTexAllPics()
|
||||||
|
report.SaveTexAllTables()
|
||||||
report.Print()
|
report.Print()
|
||||||
|
|
||||||
log.Println("looks like we're done")
|
log.Println("looks like we're done")
|
||||||
|
53
report/allTables.go
Normal file
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
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))
|
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)
|
f, err := os.Create(texTableFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user