Do test fixture setup outside cel.UnstructuredToVal benchmark loop.

This commit is contained in:
Ben Luddy 2022-06-13 15:23:25 -04:00
parent 0fe0dbf3fb
commit 91179d4ce4
No known key found for this signature in database
GPG Key ID: E01DF04B82AF03C0

View File

@ -621,11 +621,7 @@ func TestMapper(t *testing.T) {
}
func BenchmarkUnstructuredToVal(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
if val := UnstructuredToVal([]interface{}{
u := []interface{}{
map[string]interface{}{
"key": "a",
"val": 1,
@ -638,18 +634,20 @@ func BenchmarkUnstructuredToVal(b *testing.B) {
"key": "@b",
"val": 2,
},
}, &mapListSchema); val == nil {
}
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
if val := UnstructuredToVal(u, &mapListSchema); val == nil {
b.Fatal(val)
}
}
}
func BenchmarkUnstructuredToValWithEscape(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
if val := UnstructuredToVal([]interface{}{
u := []interface{}{
map[string]interface{}{
"key": "a.1",
"val": "__i.1",
@ -658,7 +656,13 @@ func BenchmarkUnstructuredToValWithEscape(b *testing.B) {
"key": "b.1",
"val": 2,
},
}, &mapListSchema); val == nil {
}
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
if val := UnstructuredToVal(u, &mapListSchema); val == nil {
b.Fatal(val)
}
}