Skip to content

Instantly share code, notes, and snippets.

@sanposhiho
Last active April 2, 2022 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanposhiho/2bab0409061bd318297526aaaf9d72b8 to your computer and use it in GitHub Desktop.
Save sanposhiho/2bab0409061bd318297526aaaf9d72b8 to your computer and use it in GitHub Desktop.
Fetch the avarage of avarages from the result of scheduler_perf in kubernetes/kubernetes
package main
import (
"encoding/json"
"fmt"
"os"
"sort"
benchmark "k8s.io/kubernetes/test/integration/scheduler_perf"
)
const projectRoot = "./test/integration/scheduler_perf/"
// run in k/k root dir.
func main() {
// TODO: rewrite the target.
targetFiles := []string{
"BenchmarkPerfScheduling_2022-04-02T07:34:37Z.json",
"BenchmarkPerfScheduling_2022-04-02T07:43:20Z.json",
}
for _, t := range targetFiles {
fmt.Println("===")
fmt.Printf("target file: %v\n", t)
b, err := os.ReadFile(projectRoot + t)
if err != nil {
panic(err)
}
var di benchmark.DataItems
err = json.Unmarshal(b, &di)
if err != nil {
panic(err)
}
result := map[string]float64{}
for _, d := range di.DataItems {
if d.Labels["Metric"] == "scheduler_framework_extension_point_duration_seconds" {
d.Labels["Metric"] = d.Labels["Metric"] + " " + d.Labels["extension_point"]
}
result[d.Labels["Metric"]] += d.Data["Average"]
}
outputs := []string{}
for i := range result {
result[i] = result[i] / float64(len(di.DataItems)/5)
outputs = append(outputs, fmt.Sprintf("metric: %v, avarage of avarages: %v", i, result[i]))
}
sort.Slice(outputs, func(i, j int) bool {
return outputs[i] > outputs[j]
})
for _, o := range outputs {
fmt.Println(o)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment