mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 09:41:57 +00:00
adding benchmark for LatestMap.Merge
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user