go(stats): implement sort.Interface for types
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
2bf3a4a767
commit
8efba25c19
@ -59,6 +59,34 @@ type Stats struct {
|
||||
Generations int
|
||||
}
|
||||
|
||||
// the following three methods implement the sort.Interface.
|
||||
func (a AlgoMean) Len() int {
|
||||
return len(a.Means)
|
||||
}
|
||||
|
||||
func (a AlgoMean) Less(i, j int) bool {
|
||||
return a.Means[i].Bench < a.Means[j].Bench
|
||||
}
|
||||
|
||||
func (a AlgoMean) Swap(i, j int) {
|
||||
a.Means[i], a.Means[j] = a.Means[j], a.Means[i]
|
||||
}
|
||||
|
||||
// the following three methods also implement the sort.Interface.
|
||||
func (m MeanStats) Len() int {
|
||||
return len(m.AlgoMeans)
|
||||
}
|
||||
|
||||
// this in fact sorts in reverse (fits with our use case atm).
|
||||
func (m MeanStats) Less(i, j int) bool {
|
||||
// return m.AlgoMeans[i].Algo < m.AlgoMeans[j].Algo
|
||||
return m.AlgoMeans[i].Algo > m.AlgoMeans[j].Algo
|
||||
}
|
||||
|
||||
func (m MeanStats) Swap(i, j int) {
|
||||
m.AlgoMeans[i], m.AlgoMeans[j] = m.AlgoMeans[j], m.AlgoMeans[i]
|
||||
}
|
||||
|
||||
func GetFuncStats(funcName string, benchResults []BenchRound) FuncStats {
|
||||
f := FuncStats{
|
||||
BenchName: funcName,
|
||||
|
Loading…
Reference in New Issue
Block a user