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

Function Benchmark_sort

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

Source from the content-addressed store, hash-verified

500}
501
502func Benchmark_sort(b *testing.B) {
503 env := map[string]any{
504 "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},
505 }
506
507 program, err := expr.Compile(`sort(arr)`, expr.Env(env))
508 require.NoError(b, err)
509
510 var out any
511 b.ResetTimer()
512 for n := 0; n < b.N; n++ {
513 out, _ = vm.Run(program, env)
514 }
515 b.StopTimer()
516
517 require.Equal(b, 1, out.([]any)[0])
518 require.Equal(b, 100, out.([]any)[99])
519}
520
521func Benchmark_sortBy(b *testing.B) {
522 type Foo struct {

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…