parent
c6d33c500d
commit
fd95e9ee13
cut_the_tree
|
@ -31,11 +31,11 @@ func Benchmark(b *testing.B) {
|
||||||
branches int
|
branches int
|
||||||
depth int
|
depth int
|
||||||
}{
|
}{
|
||||||
"Small tree":{4, 4}, // 85 nodes,
|
"Small tree (85 nodes)":{4, 4}, // 85 nodes,
|
||||||
"Wide tree": {515, 3}, // 265'741 nodes,
|
"Wide tree (2,65K nodes)": {515, 3}, // 265'741 nodes,
|
||||||
"Deep tree": {3, 12}, // 265'720 nodes,
|
"Deep tree (2,65K nodes)": {3, 12}, // 265'720 nodes,
|
||||||
"Huge tree": {5, 10}, // 2'441'406 nodes,
|
"Huge tree (2,44M nodes)": {5, 10}, // 2'441'406 nodes,
|
||||||
"Pathological tree": {1, 10000}, // 10'000 nodes,
|
"Pathological tree (10K nodes)": {1, 10000}, // 10'000 nodes,
|
||||||
}{
|
}{
|
||||||
b.Run(name, func(b *testing.B) {
|
b.Run(name, func(b *testing.B) {
|
||||||
tree := getTestTree(tt.branches, tt.depth)
|
tree := getTestTree(tt.branches, tt.depth)
|
||||||
|
@ -43,19 +43,25 @@ func Benchmark(b *testing.B) {
|
||||||
tree = TestTree{nil, nil}
|
tree = TestTree{nil, nil}
|
||||||
})
|
})
|
||||||
b.Run("Weighing with recursion", func(b *testing.B) {
|
b.Run("Weighing with recursion", func(b *testing.B) {
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
b.StartTimer()
|
b.StartTimer()
|
||||||
assert.EqualValues(b, tree.Weights, tree.Tree.WeightingTreeWithRecursion())
|
assert.EqualValues(b, tree.Weights, tree.Tree.WeightingTreeWithRecursion())
|
||||||
b.StopTimer()
|
b.StopTimer()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
b.Run("Weighting with stack", func(b *testing.B) {
|
b.Run("Weighting with stack", func(b *testing.B) {
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
b.StartTimer()
|
b.StartTimer()
|
||||||
assert.EqualValues(b, tree.Weights, tree.Tree.WeightingTreeWithStack())
|
assert.EqualValues(b, tree.Weights, tree.Tree.WeightingTreeWithStack())
|
||||||
b.StopTimer()
|
b.StopTimer()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
b.Run("Weighting with DLL", func(b *testing.B) {
|
b.Run("Weighting with DLL", func(b *testing.B) {
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
b.StartTimer()
|
b.StartTimer()
|
||||||
assert.EqualValues(b, tree.Weights, tree.Tree.WeightingTreeWithDLL())
|
assert.EqualValues(b, tree.Weights, tree.Tree.WeightingTreeWithDLL())
|
||||||
b.StopTimer()
|
b.StopTimer()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue