Sha256: 2a839b42de218d3bd07f09a9b2ed96ffcc73eb34a04cc8cbfc791f550edf435d

Contents?: true

Size: 649 Bytes

Versions: 2

Compression:

Stored size: 649 Bytes

Contents

require 'compsci/tree'
require 'minitest/autorun'
require 'minitest/benchmark'

include CompSci

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 "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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
compsci-0.0.3.1 test/bench/tree.rb
compsci-0.0.2.1 test/bench/tree.rb