diff --git a/report/latest_map_internal_test.go b/report/latest_map_internal_test.go index e0c15a50e..ce8755e7e 100644 --- a/report/latest_map_internal_test.go +++ b/report/latest_map_internal_test.go @@ -2,6 +2,7 @@ package report import ( "bytes" + "fmt" "testing" "time" @@ -134,6 +135,28 @@ func TestLatestMapMerge(t *testing.T) { } } +func BenchmarkLatestMapMerge(b *testing.B) { + var ( + left = EmptyLatestMap + right = EmptyLatestMap + now = time.Now() + ) + + // two large maps with some overlap + for i := 0; i < 1000; i++ { + left = left.Set(fmt.Sprint(i), now, "1") + } + for i := 700; i < 1700; i++ { + right = right.Set(fmt.Sprint(i), now.Add(1*time.Minute), "1") + } + + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + left.Merge(right) + } +} + func TestLatestMapEncoding(t *testing.T) { now := time.Now() want := EmptyLatestMap.