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

Function Benchmark_reduce

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

Source from the content-addressed store, hash-verified

559}
560
561func Benchmark_reduce(b *testing.B) {
562 program, err := expr.Compile(`reduce(1..100, # + #acc)`)
563 require.NoError(b, err)
564
565 var out any
566 b.ResetTimer()
567 for n := 0; n < b.N; n++ {
568 out, _ = vm.Run(program, nil)
569 }
570 b.StopTimer()
571
572 require.Equal(b, 5050, out.(int))
573}
574
575func Benchmark_min(b *testing.B) {
576 arr := []any{55, 58, 42, 61, 75, 52, 64, 62, 16, 79, 40, 14, 50, 76, 23, 2, 5, 80, 89, 51, 21, 96, 91, 13, 71, 82, 65, 63, 11, 17, 94, 81, 74, 4, 97, 1, 39, 3, 28, 8, 84, 90, 47, 85, 7, 56, 49, 93, 33, 12, 19, 60, 86, 100, 44, 45, 36, 72, 95, 77, 34, 92, 24, 73, 18, 38, 43, 26, 41, 69, 67, 57, 9, 27, 66, 87, 46, 35, 59, 70, 10, 20, 53, 15, 32, 98, 68, 31, 54, 25, 83, 88, 22, 48, 29, 37, 6, 78, 99, 30}

Callers

nothing calls this directly

Calls 4

CompileFunction · 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…