make report upgrading fast when it's a no-op

The vast majority of the cost is memory allocation, so doing a first
pass to see whether any upgrading is necessary at all, and thus
avoiding allocation when it isn't, is a massive saving.
This commit is contained in:
Matthias Radestock
2017-12-07 21:01:34 +00:00
parent 50327c9b5f
commit d528292cd4
2 changed files with 26 additions and 0 deletions

View File

@@ -67,6 +67,20 @@ func BenchmarkReportMerge(b *testing.B) {
}
}
func BenchmarkReportUpgrade(b *testing.B) {
reports, err := readReportFiles(*benchReportPath)
if err != nil {
b.Fatal(err)
}
r := NewSmartMerger().Merge(reports)
b.ResetTimer()
for i := 0; i < b.N; i++ {
r.Upgrade()
}
}
func BenchmarkTopologyList(b *testing.B) {
benchmarkRender(b, func(report report.Report) {
request := &http.Request{