app/vmselect/netstorage: add mergeSortBlocks benchmark for the worstcase

This commit is contained in:
Aliaksandr Valialkin 2022-07-12 12:26:27 +03:00
parent 076799ae29
commit 8429d4af5a
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -27,7 +27,7 @@ func BenchmarkMergeSortBlocks(b *testing.B) {
benchmarkMergeSortBlocks(b, blocks)
})
}
b.Run("overlapped-blocks", func(b *testing.B) {
b.Run("overlapped-blocks-bestcase", func(b *testing.B) {
const samplesPerBlock = 8192
var blocks []*sortBlock
for j := 0; j < 10; j++ {
@ -51,6 +51,33 @@ func BenchmarkMergeSortBlocks(b *testing.B) {
}
benchmarkMergeSortBlocks(b, blocks)
})
b.Run("overlapped-blocks-worstcase", func(b *testing.B) {
const samplesPerBlock = 8192
var blocks []*sortBlock
for j := 0; j < 5; j++ {
timestamps := make([]int64, samplesPerBlock)
values := make([]float64, samplesPerBlock)
for i := range timestamps {
timestamps[i] = int64(2 * (j*samplesPerBlock + i))
values[i] = float64(2 * (j*samplesPerBlock + i))
}
blocks = append(blocks, &sortBlock{
Timestamps: timestamps,
Values: values,
})
timestamps = make([]int64, samplesPerBlock)
values = make([]float64, samplesPerBlock)
for i := range timestamps {
timestamps[i] = int64(2*(j*samplesPerBlock+i) + 1)
values[i] = float64(2*(j*samplesPerBlock+i) + 1)
}
blocks = append(blocks, &sortBlock{
Timestamps: timestamps,
Values: values,
})
}
benchmarkMergeSortBlocks(b, blocks)
})
}
func benchmarkMergeSortBlocks(b *testing.B, blocks []*sortBlock) {