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

Function Benchmark_expr

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

Source from the content-addressed store, hash-verified

10)
11
12func Benchmark_expr(b *testing.B) {
13 params := make(map[string]any)
14 params["Origin"] = "MOW"
15 params["Country"] = "RU"
16 params["Adults"] = 1
17 params["Value"] = 100
18
19 program, err := expr.Compile(`(Origin == "MOW" || Country == "RU") && (Value >= 100 || Adults == 1)`, expr.Env(params))
20 require.NoError(b, err)
21
22 var out any
23
24 b.ResetTimer()
25 for n := 0; n < b.N; n++ {
26 out, err = vm.Run(program, params)
27 }
28 b.StopTimer()
29
30 require.NoError(b, err)
31 require.True(b, out.(bool))
32}
33
34func Benchmark_expr_eval(b *testing.B) {
35 params := make(map[string]any)

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…