MCPcopy Create free account
hub / github.com/cel-expr/cel-go / BenchmarkResolverOptionalFieldQualifier

Function BenchmarkResolverOptionalFieldQualifier

interpreter/attributes_test.go:1018–1044  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

1016}
1017
1018func BenchmarkResolverOptionalFieldQualifier(b *testing.B) {
1019 msg := &proto3pb.TestAllTypes{
1020 NestedType: &proto3pb.TestAllTypes_SingleNestedMessage{
1021 SingleNestedMessage: &proto3pb.TestAllTypes_NestedMessage{
1022 Bb: 123,
1023 },
1024 },
1025 }
1026 reg := newTestRegistry(b, types.ProtoTypeDefs(msg))
1027 attrs := NewAttributeFactory(containers.DefaultContainer, reg, reg)
1028 vars, _ := NewActivation(map[string]any{
1029 "msg": msg,
1030 })
1031 attr := attrs.AbsoluteAttribute(1, "msg")
1032 opType := types.NewObjectType("google.expr.proto3.test.TestAllTypes")
1033 fieldType := types.NewObjectType("google.expr.proto3.test.TestAllTypes.NestedMessage")
1034 attr.AddQualifier(makeOptQualifier(b, attrs, opType, 2, types.String("single_nested_message")))
1035 attr.AddQualifier(makeOptQualifier(b, attrs, types.NewOptionalType(fieldType), 3, types.String("bb")))
1036 b.ResetTimer()
1037 b.ReportAllocs()
1038 for i := 0; i < b.N; i++ {
1039 _, err := attr.Resolve(vars)
1040 if err != nil {
1041 b.Fatal(err)
1042 }
1043 }
1044}
1045
1046func TestResolverCustomQualifier(t *testing.T) {
1047 reg := newTestRegistry(t)

Callers

nothing calls this directly

Calls 11

AbsoluteAttributeMethod · 0.95
ProtoTypeDefsFunction · 0.92
NewObjectTypeFunction · 0.92
StringTypeAlias · 0.92
NewOptionalTypeFunction · 0.92
NewAttributeFactoryFunction · 0.85
makeOptQualifierFunction · 0.85
newTestRegistryFunction · 0.70
NewActivationFunction · 0.70
AddQualifierMethod · 0.65
ResolveMethod · 0.65

Tested by

no test coverage detected