2023-07-27 20:26:45 +00:00
|
|
|
package stream
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/prompbmarshal"
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/protoparser/opentelemetry/pb"
|
|
|
|
)
|
|
|
|
|
|
|
|
func BenchmarkParseStream(b *testing.B) {
|
|
|
|
samples := []*pb.Metric{
|
|
|
|
generateGauge("my-gauge"),
|
|
|
|
generateHistogram("my-histogram"),
|
|
|
|
generateSum("my-sum"),
|
|
|
|
generateSummary("my-summary"),
|
|
|
|
}
|
|
|
|
b.SetBytes(1)
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.RunParallel(func(p *testing.PB) {
|
|
|
|
pbRequest := pb.ExportMetricsServiceRequest{
|
|
|
|
ResourceMetrics: []*pb.ResourceMetrics{generateOTLPSamples(samples)},
|
|
|
|
}
|
2024-01-14 19:17:37 +00:00
|
|
|
data := pbRequest.MarshalProtobuf(nil)
|
2023-07-27 20:26:45 +00:00
|
|
|
|
|
|
|
for p.Next() {
|
2024-02-29 12:03:24 +00:00
|
|
|
err := ParseStream(bytes.NewBuffer(data), false, nil, func(tss []prompbmarshal.TimeSeries) error {
|
2023-07-27 20:26:45 +00:00
|
|
|
return nil
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
b.Fatalf("cannot parse stream: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|