test/bench/tree.rb in compsci-0.0.1.1 vs test/bench/tree.rb in compsci-0.0.2.1

- old
+ new

@@ -2,18 +2,25 @@ require 'minitest/autorun' require 'minitest/benchmark' include CompSci -describe "Tree#push Benchmark" do +describe "BinaryTree#push Benchmark" do bench_range do # note, 5000 takes way too long and is definitely not constant time # TODO: BUG? # [10, 100, 1000, 2000, 5000] [10, 100, 1000, 2000] end - bench_performance_constant "Tree#push (constant)" do |n| - tree = Tree.new Tree::Node.new 42 + bench_performance_constant "BinaryTree#push (constant)" do |n| + tree = BinaryTree.new(ChildNode, 42) + n.times { tree.push rand 99 } + end + + bench_performance_linear "BinaryTree#push (linear)" do |n| + skip "this fails with r^2 around 0.91" + + tree = BinaryTree.new ChildNode.new 42 n.times { tree.push rand 99 } end end