math-optim/report/gen.go
surtur ab850f6c2c
All checks were successful
continuous-integration/drone/push Build is passing
go(report/gen,tmpl): use more meaningful var names
2022-06-19 18:40:56 +02:00

72 lines
1009 B
Go

// Copyright 2022 wanderer <a_mirre at utb dot cz>
// SPDX-License-Identifier: GPL-3.0-or-later
//go:build ignore
// +build ignore
package main
import (
"log"
"os"
"text/template"
"time"
)
func main() {
// colAlign sets the alignment of latex table columns.
colAlign := []string{
"l",
"c",
"c",
"c",
"c",
"c",
}
results := []float64{
161.032187,
125.03484,
80321,
85.0362432,
-4.466,
66.0008,
}
colNames := []string{
"func name",
"min",
"max",
"mean",
"median",
"stdDev",
}
fName := "report.tex"
paths := []string{
"report.tmpl",
}
f, err := os.Create(fName)
if err != nil {
log.Fatal(err)
}
defer f.Close()
reportTemplate := template.Must(template.ParseFiles(paths...))
err = reportTemplate.Execute(f, struct {
Timestamp time.Time
ColNames []string
Results []float64
ColAlign []string
}{
Timestamp: time.Now(),
ColNames: colNames,
Results: results,
ColAlign: colAlign,
})
if err != nil {
log.Println(err)
}
}