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

Function BenchmarkResolverFieldQualifier

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

Source from the content-addressed store, hash-verified

819}
820
821func BenchmarkResolverFieldQualifier(b *testing.B) {
822 msg := &proto3pb.TestAllTypes{
823 NestedType: &proto3pb.TestAllTypes_SingleNestedMessage{
824 SingleNestedMessage: &proto3pb.TestAllTypes_NestedMessage{
825 Bb: 123,
826 },
827 },
828 }
829 reg := newTestRegistry(b, types.ProtoTypeDefs(msg))
830 attrs := NewAttributeFactory(containers.DefaultContainer, reg, reg)
831 vars, _ := NewActivation(map[string]any{
832 "msg": msg,
833 })
834 attr := attrs.AbsoluteAttribute(1, "msg")
835 opType, found := reg.FindType("google.expr.proto3.test.TestAllTypes")
836 if !found {
837 b.Fatal("FindType() could not find TestAllTypes")
838 }
839 fieldType, found := reg.FindType("google.expr.proto3.test.TestAllTypes.NestedMessage")
840 if !found {
841 b.Fatal("FindType() could not find NestedMessage")
842 }
843 attr.AddQualifier(makeQualifier(b, attrs, testExprTypeToType(b, opType), 2, "single_nested_message"))
844 attr.AddQualifier(makeQualifier(b, attrs, testExprTypeToType(b, fieldType), 3, "bb"))
845 b.ResetTimer()
846 for i := 0; i < b.N; i++ {
847 _, err := attr.Resolve(vars)
848 if err != nil {
849 b.Fatal(err)
850 }
851 }
852}
853
854func TestResolverCustomQualifier(t *testing.T) {
855 reg := newTestRegistry(t)

Callers

nothing calls this directly

Calls 10

AbsoluteAttributeMethod · 0.95
ProtoTypeDefsFunction · 0.92
NewAttributeFactoryFunction · 0.85
makeQualifierFunction · 0.85
testExprTypeToTypeFunction · 0.85
newTestRegistryFunction · 0.70
NewActivationFunction · 0.70
FindTypeMethod · 0.65
AddQualifierMethod · 0.65
ResolveMethod · 0.65

Tested by

no test coverage detected