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

Function Benchmark_valueAdd

patcher/value/bench_test.go:12–31  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

10)
11
12func Benchmark_valueAdd(b *testing.B) {
13 env := make(map[string]any)
14 env["ValueOne"] = &customInt{1}
15 env["ValueTwo"] = &customInt{2}
16
17 program, err := expr.Compile("ValueOne + ValueTwo", expr.Env(env), ValueGetter)
18 require.NoError(b, err)
19
20 var out any
21 v := vm.VM{}
22
23 b.ResetTimer()
24 for n := 0; n < b.N; n++ {
25 out, err = v.Run(program, env)
26 }
27 b.StopTimer()
28
29 require.NoError(b, err)
30 require.Equal(b, 3, out.(int))
31}
32
33func Benchmark_valueUntypedAdd(b *testing.B) {
34 env := make(map[string]any)

Callers

nothing calls this directly

Calls 5

RunMethod · 0.95
CompileFunction · 0.92
EnvStruct · 0.92
NoErrorFunction · 0.92
EqualFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…