Sha256: de71f0cda7d4f657080e0f3517d3c8a39f10b3cdf5db759149678487612a63de

Contents?: true

Size: 705 Bytes

Versions: 1

Compression:

Stored size: 705 Bytes

Contents

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

bad_path = %w(three_level nope nada)

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deep_tree-0.0.3 benchmarks/bad_path.rb