Skip to content

Commit

Permalink
Merge pull request #2964 from weaveworks/do-not-reportallocs
Browse files Browse the repository at this point in the history
do not report allocations in benchmarks
  • Loading branch information
rade authored Dec 8, 2017
2 parents 3251705 + d3e23e1 commit ea20de5
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 19 deletions.
8 changes: 1 addition & 7 deletions app/benchmark_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ func readReportFiles(path string) ([]report.Report, error) {
}

func BenchmarkReportUnmarshal(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
b.StopTimer()
b.StartTimer()
if _, err := readReportFiles(*benchReportPath); err != nil {
b.Fatal(err)
}
Expand All @@ -58,11 +55,9 @@ func BenchmarkReportMerge(b *testing.B) {
}
merger := NewSmartMerger()

b.ReportAllocs()
b.ResetTimer()

for i := 0; i < b.N; i++ {
b.StopTimer()
b.StartTimer()
merger.Merge(reports)
}
}
Expand Down Expand Up @@ -100,7 +95,6 @@ func benchmarkRender(b *testing.B, f func(report.Report)) {
r = NewSmartMerger().Merge(reports)
}

b.ReportAllocs()
b.ResetTimer()

for i := 0; i < b.N; i++ {
Expand Down
1 change: 0 additions & 1 deletion app/merger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func benchmarkMerger(b *testing.B, merger app.Merger) {
reports = append(reports, makeReport())
}

b.ReportAllocs()
b.ResetTimer()

for i := 0; i < b.N; i++ {
Expand Down
5 changes: 2 additions & 3 deletions common/xfer/plugin_spec_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func BenchmarkMakePluginSpecs(b *testing.B) {
for i := 1000; i >= 0; i-- {
plugins = append(plugins, PluginSpec{ID: fmt.Sprint(i)})
}
b.ReportAllocs()

b.ResetTimer()

for i := 0; i < b.N; i++ {
Expand Down Expand Up @@ -145,7 +145,6 @@ func BenchmarkPluginSpecsAdd(b *testing.B) {

plugin := PluginSpec{ID: "401.5"}

b.ReportAllocs()
b.ResetTimer()

for i := 0; i < b.N; i++ {
Expand Down Expand Up @@ -216,7 +215,7 @@ func BenchmarkPluginSpecsMerge(b *testing.B) {
for i := 400; i < 1000; i++ {
other = other.Add(PluginSpec{ID: fmt.Sprint(i)})
}
b.ReportAllocs()

b.ResetTimer()

for i := 0; i < b.N; i++ {
Expand Down
3 changes: 1 addition & 2 deletions render/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ func BenchmarkPodServiceRender(b *testing.B) {
}

func benchmarkRender(b *testing.B, r render.Renderer) {

report, err := loadReport()
if err != nil {
b.Fatal(err)
}
b.ReportAllocs()

b.ResetTimer()

for i := 0; i < b.N; i++ {
Expand Down
9 changes: 6 additions & 3 deletions report/latest_map_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,19 @@ func BenchmarkLatestMapMerge(b *testing.B) {
// two large maps with some overlap
left := makeBenchmarkMap(0, 1000, time.Now())
right := makeBenchmarkMap(700, 1700, time.Now().Add(1*time.Minute))
b.ReportAllocs()

b.ResetTimer()

for i := 0; i < b.N; i++ {
left.Merge(right)
}
}

func BenchmarkLatestMapEncode(b *testing.B) {
map1 := makeBenchmarkMap(0, 1000, time.Now())
b.ReportAllocs()

b.ResetTimer()

for i := 0; i < b.N; i++ {
buf := &bytes.Buffer{}
codec.NewEncoder(buf, &codec.MsgpackHandle{}).Encode(&map1)
Expand All @@ -157,8 +159,9 @@ func BenchmarkLatestMapDecode(b *testing.B) {
map1 := makeBenchmarkMap(0, 1000, time.Now())
buf := &bytes.Buffer{}
codec.NewEncoder(buf, &codec.MsgpackHandle{}).Encode(&map1)
b.ReportAllocs()

b.ResetTimer()

for i := 0; i < b.N; i++ {
var map1 StringLatestMap
codec.NewDecoderBytes(buf.Bytes(), &codec.MsgpackHandle{}).Decode(&map1)
Expand Down
5 changes: 2 additions & 3 deletions report/node_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func BenchmarkMakeNodeSet(b *testing.B) {
"b": "2",
}))
}
b.ReportAllocs()

b.ResetTimer()

for i := 0; i < b.N; i++ {
Expand Down Expand Up @@ -161,7 +161,6 @@ func BenchmarkNodeSetAdd(b *testing.B) {
"b": "2",
})

b.ReportAllocs()
b.ResetTimer()

for i := 0; i < b.N; i++ {
Expand Down Expand Up @@ -299,7 +298,7 @@ func BenchmarkNodeSetMerge(b *testing.B) {
}),
)
}
b.ReportAllocs()

b.ResetTimer()

for i := 0; i < b.N; i++ {
Expand Down

0 comments on commit ea20de5

Please sign in to comment.