Created
May 27, 2013 11:54
-
-
Save rummelonp/5656679 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
require 'benchmark' | |
require 'hashie/mash' | |
require 'active_support/ordered_options' | |
TIMES = 100000 | |
Benchmark.bm(30) do |x| | |
x.report('Hash') do | |
TIMES.times do | |
h = {} | |
h[:string], h[:symbol], h[:integer] = 'string', :symbol, 1 | |
[h[:string], h[:symbol], h[:integer]] | |
end | |
end | |
x.report('Hashie::Mash') do | |
TIMES.times do | |
h = Hashie::Mash.new | |
h.string, h.symbol, h.integer = 'string', :symbol, 1 | |
[h.string, h.symbol, h.integer] | |
end | |
end | |
x.report('ActiveSupport::OrderedHash') do | |
TIMES.times do | |
h = ActiveSupport::OrderedHash.new | |
h[:string], h[:symbol], h[:integer] = 'string', :symbol, 1 | |
[h[:string], h[:symbol], h[:integer]] | |
end | |
end | |
x.report('ActiveSupport::OrderedOptions') do | |
TIMES.times do | |
h = ActiveSupport::OrderedOptions.new | |
h.string, h.symbol, h.integer = 'string', :symbol, 1 | |
[h.string, h.symbol, h.integer] | |
end | |
end | |
end |
Author
rummelonp
commented
May 27, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment