Skip to content

Improve benchmark report output #3550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/cmd/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func loadSampleFile(file string) (*parser.Sample, error) {
reports := []types.Report{}
err = json.Unmarshal(data, &reports)
if err != nil {
fmt.Printf("error: %s\n", data)
fmt.Printf("failed to unmarshal report: %q\n", data)
return nil, err
}
if len(reports) < 1 {
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/cmd/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func NewSetup(specReports types.SpecReports, result map[string]Measurement) (str
data := entry.Value.AsJSON
err := json.Unmarshal([]byte(data), &xp)
if err != nil {
fmt.Printf("error: %s\n", data)
fmt.Printf("failed to unmarshal setup: %s\n", data)
return "", err
}
// in report:
Expand Down Expand Up @@ -130,7 +130,7 @@ func NewExperiments(specReports types.SpecReports, result map[string]Experiment)
data := entry.Value.AsJSON
err := json.Unmarshal([]byte(data), &xp)
if err != nil {
fmt.Printf("error: %s\n", data)
fmt.Printf("failed to unmarshal experiment: %s\n", data)
return total, err
}
// raw := entry.GetRawValue()
Expand Down
76 changes: 45 additions & 31 deletions benchmarks/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var (
input string
db string
verbose bool
debug bool
)

func main() {
Expand All @@ -42,6 +43,7 @@ func init() {
rootCmd.AddCommand(reportCmd)
rootCmd.AddCommand(csvCmd)
rootCmd.PersistentFlags().StringVarP(&input, "input", "i", "report.json", "input file")
rootCmd.PersistentFlags().BoolVarP(&debug, "debug", "", false, "debug output")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose output")

reportCmd.PersistentFlags().StringVarP(&db, "db", "d", "db/", "path to json file database dir")
Expand Down Expand Up @@ -180,7 +182,7 @@ var reportCmd = &cobra.Command{

calculate(sample, dsPop, scores)

if verbose {
if debug {
fmt.Println("# Population from DB")
fmt.Println("```")
fmt.Println(prettyPrint(dsPop))
Expand All @@ -196,40 +198,54 @@ var reportCmd = &cobra.Command{
if sample.Description != "" {
fmt.Println("# Description of Setup")
fmt.Println()
fmt.Println("> This section contains information about the setup used for the current sample. Like the k8s version, the node resources and the images available to the node.")
fmt.Println(sample.Description)
fmt.Println()
fmt.Printf("Population size: %d\n", len(population.Samples))

fmt.Println("Population Size")
fmt.Println("===============")
fmt.Printf("Reports in %q: %d\n", db, len(population.Samples))
fmt.Println()
}

t1 := report.NewTable(sample.Setup)
t1.TableStyle.EnableTextStyling = false
fmt.Println(t1.Render())

fmt.Println("# Individual Measurements")
fmt.Println("# Results for Current Sample")
fmt.Println()
fmt.Println("> These measurements were taken before and after the experiments.")
fmt.Println()

mRows := map[string]map[string]MeasurementRow{}
for experiment, xp := range sample.Experiments {
mRows[experiment] = map[string]MeasurementRow{}
for measurement, m := range xp.Measurements {
row := MeasurementRow{
Experiment: experiment,
Measurement: measurement,
Value: m.String(),
Mean: dsPop[experiment][measurement].Mean,
StdDev: dsPop[experiment][measurement].StdDev,
ZScore: dsPop[experiment][measurement].ZScore,
t := report.NewTable(sample.Setup)
t.TableStyle.EnableTextStyling = false
fmt.Println(t.Render())

if verbose {
fmt.Println("# Compare Individual Measurements to Population")
fmt.Println()
fmt.Println("> For each experiment, the measurements for the current sample are compared to the population's data.")
fmt.Println()

rows := map[string]map[string]MeasurementRow{}
for experiment, xp := range sample.Experiments {
rows[experiment] = map[string]MeasurementRow{}
for measurement, m := range xp.Measurements {
row := MeasurementRow{
Experiment: experiment,
Measurement: measurement,
Value: m.String(),
Mean: dsPop[experiment][measurement].Mean,
StdDev: dsPop[experiment][measurement].StdDev,
ZScore: dsPop[experiment][measurement].ZScore,
}
rows[experiment][measurement] = row
}
mRows[experiment][measurement] = row
}
}

mTable := newMeasurementTable(mRows)
fmt.Println(mTable.Render())
t := newMeasurementTable(rows)
fmt.Println(t.Render())
}

// table for experiments
fmt.Println("# Experiment Summary")
fmt.Println("# Summary for each Experiment")
fmt.Println()
fmt.Println("> The duration of each experiment is compared to the population's data.")
fmt.Println()

rows := map[string]Row{}
Expand All @@ -244,12 +260,12 @@ var reportCmd = &cobra.Command{
rows[experiment] = row
}

xpTable := newTable(rows)
fmt.Println(xpTable.Render())
t = newTable(rows)
fmt.Println(t.Render())

// Final score
fmt.Println("# Total Score")
fmt.Printf("%s, %.02f\n", input, scores.AvgZScores())
fmt.Println("# Final Score")
fmt.Println()
fmt.Printf("%s: %.02f\n", input, scores.AvgZScores())

return nil
},
Expand Down Expand Up @@ -288,7 +304,6 @@ func newTable(rows map[string]Row) *table.Table {
table.C("ZScore"),
table.C(""),
table.Divider("="),
//"{{bold}}",
))

keys := slices.Sorted(maps.Keys(rows))
Expand Down Expand Up @@ -326,7 +341,6 @@ func newMeasurementTable(rows map[string]map[string]MeasurementRow) *table.Table
table.C("Population StdDev"),
table.C("ZScore"),
table.Divider("="),
//"{{bold}}",
))

keys := slices.Sorted(maps.Keys(rows))
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/record/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func Nodes(ctx context.Context, experiment *gm.Experiment) {
}

func Header(s string) string {
h := fmt.Sprintf("{{bold}}%s{{/}}\n", s)
h := fmt.Sprintf("%s\n", s)
h += strings.Repeat("=", len(s)) + "\n"
return h
}
Expand Down