(b *testing.B)
| 4817 | } |
| 4818 | |
| 4819 | func 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 | |
| 4844 | func BenchmarkDynamicDispatch(b *testing.B) { |
| 4845 | env := testEnv(b, |
nothing calls this directly
no test coverage detected