MCPcopy
hub / github.com/dgraph-io/dgraph / BenchmarkMergeSorted

Function BenchmarkMergeSorted

algo/uidlist_test.go:75–107  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

73}
74
75func BenchmarkMergeSorted(b *testing.B) {
76 createList := func(n int) *pb.List {
77 list := make([]uint64, n)
78 for i := range list {
79 list[i] = uint64(rand.Int63())
80 }
81 sort.Slice(list, func(i, j int) bool {
82 return list[i] < list[j]
83 })
84 return &pb.List{Uids: list}
85 }
86
87 input := []*pb.List{}
88 for i := 0; i < 10000; i++ {
89 input = append(input, createList(100))
90 }
91
92 b.Run("MergeSorted", func(b *testing.B) {
93 for i := 0; i < b.N; i++ {
94 internalMergeSort(input)
95 }
96 })
97 b.Run("MergeSortedParallel", func(b *testing.B) {
98 for i := 0; i < b.N; i++ {
99 MergeSortedMoreMem(input)
100 }
101 })
102 b.Run("MergeSortedNew", func(b *testing.B) {
103 for i := 0; i < b.N; i++ {
104 MergeSorted(input)
105 }
106 })
107}
108
109func TestMergeSortedRandom(t *testing.T) {
110 createList := func(n int) *pb.List {

Callers

nothing calls this directly

Calls 6

internalMergeSortFunction · 0.85
MergeSortedMoreMemFunction · 0.85
MergeSortedFunction · 0.85
Int63Method · 0.80
SliceMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected