| 267 | } |
| 268 | |
| 269 | func Benchmark_envStruct_noEnv(b *testing.B) { |
| 270 | type Price struct { |
| 271 | Value int |
| 272 | } |
| 273 | type Env struct { |
| 274 | Price Price |
| 275 | } |
| 276 | |
| 277 | program, err := expr.Compile(`Price.Value > 0`) |
| 278 | require.NoError(b, err) |
| 279 | |
| 280 | env := Env{Price: Price{Value: 1}} |
| 281 | |
| 282 | var out any |
| 283 | b.ResetTimer() |
| 284 | for n := 0; n < b.N; n++ { |
| 285 | out, err = vm.Run(program, env) |
| 286 | } |
| 287 | b.StopTimer() |
| 288 | |
| 289 | require.NoError(b, err) |
| 290 | require.True(b, out.(bool)) |
| 291 | } |
| 292 | |
| 293 | func Benchmark_envMap(b *testing.B) { |
| 294 | type Price struct { |