formatted files
This commit is contained in:
parent
8bc408dea1
commit
3a9db01fa0
2 changed files with 6 additions and 6 deletions
|
@ -1,13 +1,13 @@
|
||||||
package def
|
package def
|
||||||
|
|
||||||
// the sortBy function that takes a task reference and returns the resource to consider when sorting.
|
// the sortBy function that takes a task reference and returns the resource to consider when sorting.
|
||||||
type sortBy func (task *Task) float64
|
type sortBy func(task *Task) float64
|
||||||
|
|
||||||
// Possible Sorting Criteria
|
// Possible Sorting Criteria
|
||||||
// Each holds a closure that fetches the required resource from the
|
// Each holds a closure that fetches the required resource from the
|
||||||
// given task reference.
|
// given task reference.
|
||||||
var (
|
var (
|
||||||
SortByCPU = func (task *Task) float64 {return task.CPU}
|
SortByCPU = func(task *Task) float64 { return task.CPU }
|
||||||
SortByRAM = func (task *Task) float64 {return task.RAM}
|
SortByRAM = func(task *Task) float64 { return task.RAM }
|
||||||
SortByWatts = func (task *Task) float64 {return task.Watts}
|
SortByWatts = func(task *Task) float64 { return task.Watts }
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,8 +2,8 @@ package def
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/mdesenfants/gokmeans"
|
"github.com/mdesenfants/gokmeans"
|
||||||
"sort"
|
|
||||||
"log"
|
"log"
|
||||||
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Information about a cluster of tasks
|
// Information about a cluster of tasks
|
||||||
|
@ -118,7 +118,7 @@ func labelAndOrder(clusters map[int][]Task, numberOfClusters int, taskObservatio
|
||||||
// Generic Task Sorter.
|
// Generic Task Sorter.
|
||||||
// Be able to sort an array of tasks based on any of the tasks' resources.
|
// Be able to sort an array of tasks based on any of the tasks' resources.
|
||||||
func SortTasks(ts []Task, sb sortBy) {
|
func SortTasks(ts []Task, sb sortBy) {
|
||||||
sort.SliceStable(ts, func (i, j int) bool {
|
sort.SliceStable(ts, func(i, j int) bool {
|
||||||
return sb(&ts[i]) <= sb(&ts[j])
|
return sb(&ts[i]) <= sb(&ts[j])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue