MCPcopy Index your code
hub / github.com/expr-lang/expr / Benchmark_callFast

Function Benchmark_callFast

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

Source from the content-addressed store, hash-verified

391}
392
393func Benchmark_callFast(b *testing.B) {
394 program, err := expr.Compile(`FnFast()`, expr.Env(CallEnv{}))
395 if err != nil {
396 b.Fatal(err)
397 }
398
399 env := CallEnv{
400 FnFast: func(s ...any) any {
401 return "fn_fast"
402 },
403 }
404
405 var out any
406 b.ResetTimer()
407 for n := 0; n < b.N; n++ {
408 out, err = vm.Run(program, env)
409 }
410 b.StopTimer()
411
412 require.NoError(b, err)
413 require.Equal(b, "fn_fast", out)
414}
415
416func Benchmark_callConstExpr(b *testing.B) {
417 program, err := expr.Compile(`Func()`, expr.Env(CallEnv{}), expr.ConstExpr("Func"))

Callers

nothing calls this directly

Calls 5

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