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

Function BenchmarkResolverFieldQualifier

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

Source from the content-addressed store, hash-verified

982}
983
984func BenchmarkResolverFieldQualifier(b *testing.B) {
985 msg := &proto3pb.TestAllTypes{
986 NestedType: &proto3pb.TestAllTypes_SingleNestedMessage{
987 SingleNestedMessage: &proto3pb.TestAllTypes_NestedMessage{
988 Bb: 123,
989 },
990 },
991 }
992 reg := newTestRegistry(b, types.ProtoTypeDefs(msg))
993 attrs := NewAttributeFactory(containers.DefaultContainer, reg, reg)
994 vars, _ := NewActivation(map[string]any{
995 "msg": msg,
996 })
997 attr := attrs.AbsoluteAttribute(1, "msg")
998 opType, found := reg.FindType("google.expr.proto3.test.TestAllTypes")
999 if !found {
1000 b.Fatal("FindType() could not find TestAllTypes")
1001 }
1002 fieldType, found := reg.FindType("google.expr.proto3.test.TestAllTypes.NestedMessage")
1003 if !found {
1004 b.Fatal("FindType() could not find NestedMessage")
1005 }
1006 attr.AddQualifier(makeQualifier(b, attrs, testExprTypeToType(b, opType), 2, "single_nested_message"))
1007 attr.AddQualifier(makeQualifier(b, attrs, testExprTypeToType(b, fieldType), 3, "bb"))
1008 b.ResetTimer()
1009 b.ReportAllocs()
1010 for i := 0; i < b.N; i++ {
1011 _, err := attr.Resolve(vars)
1012 if err != nil {
1013 b.Fatal(err)
1014 }
1015 }
1016}
1017
1018func BenchmarkResolverOptionalFieldQualifier(b *testing.B) {
1019 msg := &proto3pb.TestAllTypes{

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