Sha256: 4c34f0d489caaa69639a23406465fbe37a79a62fdc211f796fc1a6b54ed95227

Contents?: true

Size: 738 Bytes

Versions: 1

Compression:

Stored size: 738 Bytes

Contents

require File.join(File.dirname(__FILE__), 'benchmark_helper')

good_path = %w(three_level level_two level_one)

puts "Good Path"
Benchmark.bm do |x|
  x.report('DeepTree::get_leaf') do
    $iterations.times { DeepTree.get_leaf($hash, *good_path) }
  end
  x.report('Hash#get_leaf     ') do
    $iterations.times { $hash.get_leaf($hash, *good_path) }
  end
  x.report('DeepTree#get_leaf ') do
    $iterations.times { tree = DeepTree.new($hash); tree.get_leaf($hash, *good_path) }
  end
  x.report('Hash[] w/ rescue  ') do
    $iterations.times { $hash['three_level']['level_two']['level_one'] rescue nil }
  end
  x.report('Hashie::Mash      ') do
    $iterations.times { Hashie::Mash.new($hash).three_level.level_two.level_one }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deep_tree-0.0.3 benchmarks/good_path.rb