From 8aba6dc661e71ffb50c3825c445d451ac5db0d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 13 Nov 2024 14:54:15 +0100 Subject: [PATCH] parser/metadecoders: Add benchmark --- parser/metadecoders/decoder_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/parser/metadecoders/decoder_test.go b/parser/metadecoders/decoder_test.go index 734713c2e..49f7868cc 100644 --- a/parser/metadecoders/decoder_test.go +++ b/parser/metadecoders/decoder_test.go @@ -306,3 +306,26 @@ func BenchmarkStringifyMapKeysIntegers(b *testing.B) { stringifyMapKeys(maps[i]) } } + +func BenchmarkDecodeYAMLToMap(b *testing.B) { + d := Default + + data := []byte(` +a: + v1: 32 + v2: 43 + v3: "foo" +b: + - a + - b +c: "d" + +`) + + for i := 0; i < b.N; i++ { + _, err := d.UnmarshalToMap(data, YAML) + if err != nil { + b.Fatal(err) + } + } +}