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

Function Benchmark_largeStructAccess

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

Source from the content-addressed store, hash-verified

431}
432
433func Benchmark_largeStructAccess(b *testing.B) {
434 type Env struct {
435 Data [1024 * 1024 * 10]byte
436 Field int
437 }
438
439 program, err := expr.Compile(`Field > 0 && Field > 1 && Field < 99`, expr.Env(Env{}))
440 require.NoError(b, err)
441
442 env := Env{Field: 21}
443
444 var out any
445 b.ResetTimer()
446 for n := 0; n < b.N; n++ {
447 out, err = vm.Run(program, &env)
448 }
449 b.StopTimer()
450
451 require.NoError(b, err)
452 require.True(b, out.(bool))
453}
454
455func Benchmark_largeNestedStructAccess(b *testing.B) {
456 type Env struct {

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…