(b *testing.B)
| 11 | ) |
| 12 | |
| 13 | func 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 | } |
nothing calls this directly
no test coverage detected