mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-19 07:01:02 +01:00
40 lines
900 B
Go
40 lines
900 B
Go
|
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)},
|
||
|
}
|
||
|
data, err := pbRequest.MarshalVT()
|
||
|
if err != nil {
|
||
|
b.Fatalf("cannot marshal data: %s", err)
|
||
|
}
|
||
|
|
||
|
for p.Next() {
|
||
|
err := ParseStream(bytes.NewBuffer(data), false, func(tss []prompbmarshal.TimeSeries) error {
|
||
|
return nil
|
||
|
})
|
||
|
if err != nil {
|
||
|
b.Fatalf("cannot parse stream: %s", err)
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
|
||
|
}
|