MCPcopy Create free account
hub / github.com/brimdata/super / BenchmarkSort

Function BenchmarkSort

runtime/sam/expr/sort_test.go:13–38  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

11)
12
13func BenchmarkSort(b *testing.B) {
14 cases := []struct {
15 typ super.Type
16 bytes func() []byte
17 }{
18 {super.TypeInt64, func() []byte { return super.EncodeInt(int64(rand.Uint64())) }},
19 {super.TypeUint64, func() []byte { return super.EncodeUint(rand.Uint64()) }},
20 {super.TypeString, func() []byte { return strconv.AppendUint(nil, rand.Uint64(), 16) }},
21 {super.TypeDuration, func() []byte { return super.EncodeInt(int64(rand.Uint64())) }},
22 {super.TypeTime, func() []byte { return super.EncodeInt(int64(rand.Uint64())) }},
23 }
24 for _, c := range cases {
25 b.Run(sup.FormatType(c.typ), func(b *testing.B) {
26 cmp := NewComparator(SortExpr{&This{}, order.Asc, order.NullsLast})
27 vals := make([]super.Value, 1048576)
28 for b.Loop() {
29 b.StopTimer()
30 for i := range vals {
31 vals[i] = super.NewValue(c.typ, c.bytes())
32 }
33 b.StartTimer()
34 cmp.SortStable(vals)
35 }
36 })
37 }
38}

Callers

nothing calls this directly

Calls 8

SortStableMethod · 0.95
EncodeIntFunction · 0.92
EncodeUintFunction · 0.92
FormatTypeFunction · 0.92
NewValueFunction · 0.92
bytesMethod · 0.80
NewComparatorFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected