Skip to content

Draw min/max as area #3

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
38 changes: 24 additions & 14 deletions benchplot/plot.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"image/color"
"math"

"github.com/aclements/go-gg/generic/slice"
Expand Down Expand Up @@ -33,51 +34,60 @@ func plot(t, git table.Grouping, configCols, resultCols []string) (*gg.Plot, int
plot.SortBy("commit date")
plot.Stat(commitIndex{})

// Average each result at each commit (but keep columns names
// the same to keep things easier to read).
plot.Stat(ggstat.Agg("commit", "name")(ggstat.AggMean(resultCols...)))
for _, rcol := range resultCols {
plot.SetData(table.Rename(plot.Data(), "mean "+rcol, rcol))
}

// Unpivot all of the metrics into one column.
plot.Stat(convertFloat{resultCols})
plot.SetData(table.Unpivot(plot.Data(), "metric", "result", resultCols...))
y := "result"

// Average each result at each commit (but keep columns names
// the same to keep things easier to read).
plot.Stat(ggstat.Agg("commit", "name", "metric", "branch", "commit index")(ggstat.AggMean("result"), ggstat.AggMin("result"), ggstat.AggMax("result")))
y := "mean result"

// Normalize to earliest commit on master. It's important to
// do this before the geomean if there are commits missing.
// Unfortunately, that also means we have to *temporarily*
// group by name and metric, since the geomean needs to be
// done on a different grouping.
plot.GroupBy("name", "metric")
plot.Stat(ggstat.Normalize{X: "branch", By: firstMasterIndex, Cols: []string{"result"}})
plot.Stat(ggstat.Normalize{X: "branch", By: firstMasterIndex, Cols: []string{"mean result", "max result", "min result"}, DenomCols: []string{"mean result", "mean result", "mean result"}})
y = "normalized " + y
plot.SetData(table.Remove(plot.Data(), "result"))
for _, col := range []string{"mean result", "max result", "min result"} {
plot.SetData(table.Remove(plot.Data(), col))
}
plot.SetData(table.Ungroup(table.Ungroup(plot.Data())))

// Compute geomean for each metric at each commit if there's
// more than one benchmark.
if len(table.GroupBy(t, "name").Tables()) > 1 {
gt := removeNaNs(plot.Data(), y)
gt = ggstat.Agg("commit", "metric")(ggstat.AggGeoMean(y)).F(gt)
gt = ggstat.Agg("commit", "metric", "branch", "commit index")(ggstat.AggGeoMean(y), ggstat.AggMin("normalized min result"), ggstat.AggMax("normalized max result")).F(gt)
gt = table.MapTables(gt, func(_ table.GroupID, t *table.Table) *table.Table {
return table.NewBuilder(t).AddConst("name", " geomean").Done()
})
gt = table.Rename(gt, "geomean "+y, y)
gt = table.Rename(gt, "min normalized min result", "normalized min result")
gt = table.Rename(gt, "max normalized max result", "normalized max result")
plot.SetData(table.Concat(plot.Data(), gt))
nrows++
}

// Always show Y=0.
plot.SetScale("y", gg.NewLinearScaler().Include(0))

// Facet by name and metric.
plot.Add(gg.FacetY{Col: "name"}, gg.FacetX{Col: "metric"})
plot.Add(gg.FacetY{Col: "name"}, gg.FacetX{Col: "metric", SplitYScales: true})

// Filter the data to reduce noise.
plot.Stat(kza{y, 15, 3})
y = "filtered " + y

// Always show Y=0.
plot.SetScale("y", gg.NewLinearScaler().Include(0))
plot.Add(gg.LayerArea{
X: "commit index",
Upper: "normalized max result",
Lower: "normalized min result",
Fill: plot.Const(color.Gray{192}),
//Color: "branch",
})

plot.Add(gg.LayerLines{
X: "commit index",
Expand Down
19 changes: 15 additions & 4 deletions benchplot/vendor/github.com/aclements/go-gg/generic/slice/sort.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 39 additions & 1 deletion benchplot/vendor/github.com/aclements/go-gg/gg/layer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions benchplot/vendor/github.com/aclements/go-gg/gg/layout.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 45 additions & 6 deletions benchplot/vendor/github.com/aclements/go-gg/gg/mark.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading