Skip to content

Commit

Permalink
Add a micro benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
cyriltovena committed Nov 14, 2024
1 parent 955e67c commit a7d36c5
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions pkg/chunkenc/memchunk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,37 @@ func BenchmarkRead(b *testing.B) {
}
}

func BenchmarkReadWithStructuredMetadata(b *testing.B) {
b.Run("v5", func(b *testing.B) {
c := NewMemChunk(ChunkFormatV5, compression.Snappy, UnorderedWithOrganizedStructuredMetadataHeadBlockFmt, testBlockSize, testTargetSize)
fillChunk(c)
b.ResetTimer()
ctx := context.Background()
for n := 0; n < b.N; n++ {
iterator := c.SampleIterator(ctx, time.Unix(0, 0), time.Now(), countExtractor, true)
for iterator.Next() {
}
if err := iterator.Close(); err != nil {
b.Fatal(err)
}
}
})
// b.Run("v5", func(b *testing.B) {
// c := NewMemChunk(ChunkFormatV4, compression.Snappy, UnorderedWithStructuredMetadataHeadBlockFmt, testBlockSize, testTargetSize)
// fillChunk(c)
// b.ResetTimer()
// ctx := context.Background()
// for n := 0; n < b.N; n++ {
// iterator := c.SampleIterator(ctx, time.Unix(0, 0), time.Now(), countExtractor, true)
// for iterator.Next() {
// }
// if err := iterator.Close(); err != nil {
// b.Fatal(err)
// }
// }
// })
}

type noopTestPipeline struct{}

func (noopTestPipeline) BaseLabels() log.LabelsResult { return log.EmptyLabelsResult }
Expand Down

0 comments on commit a7d36c5

Please sign in to comment.