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

Function Benchmark_expr_reuseVm

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

Source from the content-addressed store, hash-verified

52}
53
54func Benchmark_expr_reuseVm(b *testing.B) {
55 params := make(map[string]any)
56 params["Origin"] = "MOW"
57 params["Country"] = "RU"
58 params["Adults"] = 1
59 params["Value"] = 100
60
61 program, err := expr.Compile(`(Origin == "MOW" || Country == "RU") && (Value >= 100 || Adults == 1)`, expr.Env(params))
62 require.NoError(b, err)
63
64 var out any
65 v := vm.VM{}
66
67 b.ResetTimer()
68 for n := 0; n < b.N; n++ {
69 out, err = v.Run(program, params)
70 }
71 b.StopTimer()
72
73 require.NoError(b, err)
74 require.True(b, out.(bool))
75}
76
77func Benchmark_len(b *testing.B) {
78 env := map[string]any{

Callers

nothing calls this directly

Calls 5

RunMethod · 0.95
CompileFunction · 0.92
EnvStruct · 0.92
NoErrorFunction · 0.92
TrueFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…