go: include 'comparison of means' in the reports
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
* add logic + tmpl that handles collecting 'comparison of means' plots
This commit is contained in:
parent
37d761bf81
commit
78dbe2cc0b
75
report/comparisonOfMeans.go
Normal file
75
report/comparisonOfMeans.go
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
// Copyright 2022 wanderer <a_mirre at utb dot cz>
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
package report
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "embed"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"text/template"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"git.dotya.ml/wanderer/math-optim/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:embed comparisonOfMeans.tmpl
|
||||||
|
var tmplComparisonOfMeansFile []byte
|
||||||
|
|
||||||
|
// SaveComparisonOfMeans saves each pic in the list to file, takes note of the
|
||||||
|
// saved file names.
|
||||||
|
func SaveComparisonOfMeans(p PicList, benchCount int) {
|
||||||
|
// algos contains a title of sorts in the form "Algo vs Algo vs Algo...",
|
||||||
|
// i.e. p.Algo has been repurposed in this instance to contain the names
|
||||||
|
// of all pertaining algos.
|
||||||
|
algos := p.Algo
|
||||||
|
texfiles := picTexFiles{Algo: "Comparison of Algo Means: " + algos}
|
||||||
|
safeName := util.SanitiseFName(algos)
|
||||||
|
texPicsFile := fmt.Sprintf("%spics-%s.tex", GetTexDir(), safeName)
|
||||||
|
tmplComparisonOfMeans := template.New("comparisonofmeans")
|
||||||
|
tmplComparisonOfMeans = template.Must(
|
||||||
|
tmplComparisonOfMeans.Parse(string(tmplComparisonOfMeansFile)),
|
||||||
|
)
|
||||||
|
benchPicLists := make([]PicList, 0, benchCount)
|
||||||
|
|
||||||
|
// split the slice to smaller, per-bench slices.
|
||||||
|
for i := 0; i < len(p.Pics); i += benchCount {
|
||||||
|
pL := &PicList{}
|
||||||
|
pL.Pics = p.Pics[i : i+benchCount]
|
||||||
|
pL.Bench = p.Pics[i].Bench
|
||||||
|
benchPicLists = append(benchPicLists, *pL)
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure the output dir exists, else die early.
|
||||||
|
if err := util.CreatePath(GetTexDir()); err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
f, err := os.Create(texPicsFile)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
err = tmplComparisonOfMeans.Execute(f, struct {
|
||||||
|
Title string
|
||||||
|
Bench string
|
||||||
|
BenchCount int
|
||||||
|
PicLists []PicList
|
||||||
|
Timestamp time.Time
|
||||||
|
}{
|
||||||
|
Title: p.Algo,
|
||||||
|
Bench: p.Bench,
|
||||||
|
BenchCount: benchCount,
|
||||||
|
PicLists: benchPicLists,
|
||||||
|
Timestamp: time.Now(),
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
texfiles.FilePaths = []string{texPicsFile}
|
||||||
|
allPics.TexFiles = append(allPics.TexFiles, texfiles)
|
||||||
|
}
|
25
report/comparisonOfMeans.tmpl
Normal file
25
report/comparisonOfMeans.tmpl
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
% Code generated by math-optim; DO NOT EDIT.
|
||||||
|
%
|
||||||
|
% This file was generated by robots at
|
||||||
|
% {{ .Timestamp }}
|
||||||
|
% 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/
|
||||||
|
|
||||||
|
%\subsection{ {{- printf "Comparison of algo means: %s" .Title -}} }
|
||||||
|
{{ range $i, $v := .PicLists }}
|
||||||
|
\subsection{ {{- (index $v.Pics 0).Bench -}} }
|
||||||
|
\begin{figure}[h!]
|
||||||
|
\centering
|
||||||
|
{{- range $j, $u := $v.Pics }}
|
||||||
|
\begin{subfigure}{0.30\textwidth}
|
||||||
|
{\includesvg[scale=0.45]{ {{- printf "%s" $u.FilePath -}} }}
|
||||||
|
\caption{ {{- printf "\\scriptsize{%s}" $u.Caption -}} }
|
||||||
|
\end{subfigure}
|
||||||
|
\hfill
|
||||||
|
{{- end }}
|
||||||
|
\caption{ {{- printf "{Bench: %s}" $v.Bench }} }
|
||||||
|
\end{figure}
|
||||||
|
\newpage
|
||||||
|
{{ end }}
|
3
run.go
3
run.go
@ -36,6 +36,9 @@ func run() {
|
|||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
pL, benchCount := algo.PrepComparisonOfMeans(&wg)
|
||||||
|
|
||||||
|
report.SaveComparisonOfMeans(*pL, benchCount)
|
||||||
report.SaveTexAllPics()
|
report.SaveTexAllPics()
|
||||||
report.SaveTexAllTables()
|
report.SaveTexAllTables()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user