chore(parsers.xpath): Add benchmark for CBOR format (#14314)

This commit is contained in:
Sven Rebhan 2023-11-16 18:14:40 +01:00 committed by GitHub
parent be88a340de
commit 4f94850c1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 0 deletions

View File

@ -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)
}
}

View File

@ -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

View File

@ -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"