Sha256: f58e2803287f9c9da7da1ae04a06cc2a94c4a319a6fabd987d45138415b86141
Contents?: true
Size: 625 Bytes
Versions: 6
Compression:
Stored size: 625 Bytes
Contents
require 'benchmark' require 'ostruct' require_relative 'lib/structure' class Person1 < Structure key :name end class Person2 < Struct.new(:name) end class Person3 attr_accessor :name end n = 100000 Benchmark.bm do |x| x.report('Structure') { n.times { Person1.new(:name => 'John') } } x.report('Structure') { n.times { Person1.new.name = 'John' } } x.report('OpenStruct') { n.times { OpenStruct.new(:name => 'John') } } x.report('Struct') { n.times { Person2.new('John') } } x.report('Class') { n.times { Person3.new.name = 'John' } } x.report('Hash') { n.times { { name: 'John' } } } end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
structure-0.12.2 | benchmark.rb |
structure-0.12.1 | benchmark.rb |
structure-0.12.0 | benchmark.rb |
structure-0.11.0 | benchmark.rb |
structure-0.10.0 | benchmark.rb |
structure-0.9.0 | benchmark.rb |