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

Function Benchmark_envStruct

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

Source from the content-addressed store, hash-verified

243}
244
245func 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
269func Benchmark_envStruct_noEnv(b *testing.B) {
270 type Price struct {

Callers

nothing calls this directly

Calls 5

CompileFunction · 0.92
EnvStruct · 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…