adding benchmark for LatestMap.Merge

This commit is contained in:
Paul Bellamy
2016-05-10 10:48:54 +01:00
parent 66814f3512
commit 52c2498373

View File

@@ -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.