MCPcopy Create free account
hub / github.com/expr-lang/expr / BenchmarkSumArray

Function BenchmarkSumArray

optimizer/sum_array_test.go:16–36  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

14)
15
16func BenchmarkSumArray(b *testing.B) {
17 env := map[string]any{
18 "a": 1,
19 "b": 2,
20 "c": 3,
21 "d": 4,
22 }
23
24 program, err := expr.Compile(`sum([a, b, c, d])`, expr.Env(env))
25 require.NoError(b, err)
26
27 var out any
28 b.ResetTimer()
29 for n := 0; n < b.N; n++ {
30 out, err = vm.Run(program, env)
31 }
32 b.StopTimer()
33
34 require.NoError(b, err)
35 require.Equal(b, 10, out)
36}
37
38func TestOptimize_sum_array(t *testing.T) {
39 tree, err := parser.Parse(`sum([a, b])`)

Callers

nothing calls this directly

Calls 5

CompileFunction · 0.92
EnvStruct · 0.92
NoErrorFunction · 0.92
RunFunction · 0.92
EqualFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…