diff --git a/report/pic.go b/report/pic.go index 3d709db..582a9f1 100644 --- a/report/pic.go +++ b/report/pic.go @@ -23,16 +23,34 @@ type Pic struct { Bench string // optionally set. } +type PlotPics []Pic + // PicList is a structure holding a slice of pics and {bench,algo} metadata. type PicList struct { Algo string Bench string - Pics []Pic + Pics PlotPics } //go:embed pics.tmpl var tmplPicsFile []byte +// Len implements the sort.Interface. +func (p PlotPics) Len() int { + return len(p) +} + +// Less implements the sort.Interface. +// note: sorting based on filename +func (p PlotPics) Less(i, j int) bool { + return p[i].FilePath < p[j].FilePath +} + +// Swap implements the sort.Interface. +func (p PlotPics) Swap(i, j int) { + p[i], p[j] = p[j], p[i] +} + // NewPic returns a new copy of Pic. func NewPic() *Pic { return &Pic{}