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

Function BenchmarkOptionalValues

cel/cel_test.go:4819–4842  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

4817}
4818
4819func BenchmarkOptionalValues(b *testing.B) {
4820 env := testEnv(b,
4821 OptionalTypes(),
4822 Variable("x", OptionalType(IntType)),
4823 Variable("y", OptionalType(IntType)),
4824 Variable("z", IntType),
4825 )
4826 ast, iss := env.Compile("x.or(y).orValue(z)")
4827 if iss.Err() != nil {
4828 b.Fatalf("env.Compile(x.or(y).orValue(z)) failed: %v", iss.Err())
4829 }
4830 prg, err := env.Program(ast, EvalOptions(OptOptimize))
4831 if err != nil {
4832 b.Errorf("env.Program() failed: %v", err)
4833 }
4834 input := map[string]any{
4835 "x": types.OptionalNone,
4836 "y": types.OptionalNone,
4837 "z": 42,
4838 }
4839 for i := 0; i < b.N; i++ {
4840 prg.Eval(input)
4841 }
4842}
4843
4844func BenchmarkDynamicDispatch(b *testing.B) {
4845 env := testEnv(b,

Callers

nothing calls this directly

Calls 8

OptionalTypesFunction · 0.85
EvalOptionsFunction · 0.85
ErrMethod · 0.80
ProgramMethod · 0.80
testEnvFunction · 0.70
VariableFunction · 0.70
CompileMethod · 0.65
EvalMethod · 0.65

Tested by

no test coverage detected