chore(parsers.xpath): Add benchmark for CBOR format (#14314)
This commit is contained in:
parent
be88a340de
commit
4f94850c1d
|
|
@ -1781,3 +1781,35 @@ func BenchmarkParsingMsgPack(b *testing.B) {
|
|||
_, _ = plugin.Parse(benchmarkDataMsgPack[n%2])
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkParsingCBOR(b *testing.B) {
|
||||
plugin := &Parser{
|
||||
DefaultMetricName: "benchmark",
|
||||
Format: "xpath_cbor",
|
||||
NativeTypes: true,
|
||||
Configs: []Config{
|
||||
{
|
||||
Selection: "//data",
|
||||
Timestamp: "timestamp",
|
||||
TimestampFmt: "unix_ns",
|
||||
Tags: map[string]string{
|
||||
"source": "source",
|
||||
"tags_sdkver": "tags_sdkver",
|
||||
"tags_platform": "tags_platform",
|
||||
},
|
||||
Fields: map[string]string{
|
||||
"value": "value",
|
||||
},
|
||||
},
|
||||
},
|
||||
Log: testutil.Logger{Name: "parsers.xpath", Quiet: true},
|
||||
}
|
||||
require.NoError(b, plugin.Init())
|
||||
|
||||
benchmarkData, err := os.ReadFile(filepath.Join("testcases", "cbor_benchmark", "message.bin"))
|
||||
require.NoError(b, err)
|
||||
|
||||
for n := 0; n < b.N; n++ {
|
||||
_, _ = plugin.Parse(benchmarkData)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
benchmark,source=myhost,tags_platform=python,tags_sdkver=3.11.5 value=5.0 1653643421000000000
|
||||
benchmark,source=myhost,tags_platform=python,tags_sdkver=3.11.4 value=4.0 1653643421000000000
|
||||
Binary file not shown.
|
|
@ -0,0 +1,20 @@
|
|||
[[inputs.file]]
|
||||
files = ["./testcases/cbor_benchmark/message.bin"]
|
||||
data_format = "xpath_cbor"
|
||||
|
||||
xpath_native_types = true
|
||||
|
||||
[[inputs.file.xpath]]
|
||||
metric_name = "'benchmark'"
|
||||
metric_selection = "//data"
|
||||
|
||||
timestamp = "timestamp"
|
||||
timestamp_format = "unix_ns"
|
||||
|
||||
[inputs.file.xpath.tags]
|
||||
source = "source"
|
||||
tags_sdkver = "tags_sdkver"
|
||||
tags_platform = "tags_platform"
|
||||
|
||||
[inputs.file.xpath.fields]
|
||||
value = "value"
|
||||
Loading…
Reference in New Issue