Created
May 2, 2015 18:46
-
-
Save ianks/15362d1a28e24d57fe41 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
#!/usr/bin/env ruby | |
require 'benchmark' | |
class StateClass | |
def initialize(value, mark) | |
@value, @mark = value, mark | |
end | |
end | |
class StateStruct < Struct.new(:value, :mark); end | |
count = 10_000_000 | |
Benchmark.bmbm do |x| | |
x.report('StateClass') { count.times { StateClass.new('test', true).freeze } } | |
x.report('StateStruct') { count.times { StateStruct.new('test', true).freeze } } | |
x.report('StateArray') { count.times { ['test', true].freeze } } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment