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