add benchmarks for report summarization

This is the last phase before result marshalling in the
/api/topology/{name} handler.
This commit is contained in:
Matthias Radestock
2017-12-24 09:48:41 +00:00
parent 06e0bed015
commit f4668ca692

View File

@@ -9,6 +9,7 @@ import (
"testing"
"github.com/weaveworks/scope/render"
"github.com/weaveworks/scope/render/detailed"
"github.com/weaveworks/scope/report"
"github.com/weaveworks/scope/test/fixture"
)
@@ -129,3 +130,33 @@ func BenchmarkRenderContainers(b *testing.B) {
func BenchmarkRenderProcesses(b *testing.B) {
benchmarkRenderTopology(b, "processes")
}
func benchmarkSummarizeTopology(b *testing.B, topologyID string) {
r := getReport(b)
rc := report.RenderContext{Report: r}
nodes := renderForTopology(b, topologyID, r)
b.ResetTimer()
for i := 0; i < b.N; i++ {
detailed.Summaries(rc, nodes)
}
}
func BenchmarkSummarizeHosts(b *testing.B) {
benchmarkSummarizeTopology(b, "hosts")
}
func BenchmarkSummarizeControllers(b *testing.B) {
benchmarkSummarizeTopology(b, "kube-controllers")
}
func BenchmarkSummarizePods(b *testing.B) {
benchmarkSummarizeTopology(b, "pods")
}
func BenchmarkSummarizeContainers(b *testing.B) {
benchmarkSummarizeTopology(b, "containers")
}
func BenchmarkSummarizeProcesses(b *testing.B) {
benchmarkSummarizeTopology(b, "processes")
}