mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Merge pull request #604 from prometheus/beorn7/benchmark
Add benchmark for loading chunks and chunk descs.
This commit is contained in:
commit
b841ae41cd
BIN
storage/local/fixtures/b0/04b821ca50ba26.db
Normal file
BIN
storage/local/fixtures/b0/04b821ca50ba26.db
Normal file
Binary file not shown.
BIN
storage/local/fixtures/b0/37c21e884e4fc5.db
Normal file
BIN
storage/local/fixtures/b0/37c21e884e4fc5.db
Normal file
Binary file not shown.
BIN
storage/local/fixtures/b0/37de1e884e5469.db
Normal file
BIN
storage/local/fixtures/b0/37de1e884e5469.db
Normal file
Binary file not shown.
|
@ -884,3 +884,74 @@ func verifyIndexedState(i int, t *testing.T, b incrementalBatch, indexedFpsToMet
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
var fpStrings = []string{
|
||||
"b004b821ca50ba26",
|
||||
"b037c21e884e4fc5",
|
||||
"b037de1e884e5469",
|
||||
}
|
||||
|
||||
func BenchmarkLoadChunksSequentially(b *testing.B) {
|
||||
p := persistence{
|
||||
basePath: "fixtures",
|
||||
}
|
||||
sequentialIndexes := make([]int, 47)
|
||||
for i := range sequentialIndexes {
|
||||
sequentialIndexes[i] = i
|
||||
}
|
||||
|
||||
var fp clientmodel.Fingerprint
|
||||
for i := 0; i < b.N; i++ {
|
||||
for _, s := range fpStrings {
|
||||
fp.LoadFromString(s)
|
||||
cds, err := p.loadChunks(fp, sequentialIndexes, 0)
|
||||
if err != nil {
|
||||
b.Error(err)
|
||||
}
|
||||
if len(cds) == 0 {
|
||||
b.Error("could not read any chunks")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLoadChunksRandomly(b *testing.B) {
|
||||
p := persistence{
|
||||
basePath: "fixtures",
|
||||
}
|
||||
randomIndexes := []int{1, 5, 6, 8, 11, 14, 18, 23, 29, 33, 42, 46}
|
||||
|
||||
var fp clientmodel.Fingerprint
|
||||
for i := 0; i < b.N; i++ {
|
||||
for _, s := range fpStrings {
|
||||
fp.LoadFromString(s)
|
||||
cds, err := p.loadChunks(fp, randomIndexes, 0)
|
||||
if err != nil {
|
||||
b.Error(err)
|
||||
}
|
||||
if len(cds) == 0 {
|
||||
b.Error("could not read any chunks")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLoadChunkDescs(b *testing.B) {
|
||||
p := persistence{
|
||||
basePath: "fixtures",
|
||||
}
|
||||
|
||||
var fp clientmodel.Fingerprint
|
||||
for i := 0; i < b.N; i++ {
|
||||
for _, s := range fpStrings {
|
||||
fp.LoadFromString(s)
|
||||
cds, err := p.loadChunkDescs(fp, clientmodel.Latest)
|
||||
if err != nil {
|
||||
b.Error(err)
|
||||
}
|
||||
if len(cds) == 0 {
|
||||
b.Error("could not read any chunk descs")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue