MCPcopy
hub / github.com/expr-lang/expr / Benchmark_envStruct_noEnv

Function Benchmark_envStruct_noEnv

bench_test.go:269–291  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

267}
268
269func 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
293func Benchmark_envMap(b *testing.B) {
294 type Price struct {

Callers

nothing calls this directly

Calls 4

CompileFunction · 0.92
NoErrorFunction · 0.92
RunFunction · 0.92
TrueFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…