| 243 | } |
| 244 | |
| 245 | func Benchmark_envStruct(b *testing.B) { |
| 246 | type Price struct { |
| 247 | Value int |
| 248 | } |
| 249 | type Env struct { |
| 250 | Price Price |
| 251 | } |
| 252 | |
| 253 | program, err := expr.Compile(`Price.Value > 0`, expr.Env(Env{})) |
| 254 | require.NoError(b, err) |
| 255 | |
| 256 | env := Env{Price: Price{Value: 1}} |
| 257 | |
| 258 | var out any |
| 259 | b.ResetTimer() |
| 260 | for n := 0; n < b.N; n++ { |
| 261 | out, err = vm.Run(program, env) |
| 262 | } |
| 263 | b.StopTimer() |
| 264 | |
| 265 | require.NoError(b, err) |
| 266 | require.True(b, out.(bool)) |
| 267 | } |
| 268 | |
| 269 | func Benchmark_envStruct_noEnv(b *testing.B) { |
| 270 | type Price struct { |