require 'compsci/complete_tree' require 'compsci/timer' require 'compsci/fit' include CompSci timing = {} ns = [10, 100, 1000, 10_000, 100_000] # Note, CompleteTree is a very thin wrapper around Array, so we are just # testing ruby's inherent Array performance here. # Append / push / insert is constant for ruby Arrays. puts < 1 } a, b, r2, fn = Fit.best timing.keys, timing.values puts "best fit: #{fn} (%0.3f); a = %0.6f, b = %0.6f" % [r2, a, b] puts < 1 } a, b, r2, fn = Fit.best timing.keys, timing.values puts "best fit: #{fn} (%0.3f); a = %0.6f, b = %0.6f" % [r2, a, b]