Sha256: b71879a08d3038405a820824b4e698f6bb24f9a00782311e4bc74452e8e05d91
Contents?: true
Size: 462 Bytes
Versions: 13
Compression:
Stored size: 462 Bytes
Contents
require 'benchmark' # Point = Struct.new :x, :y # class Point # attr_accessor :x, :y # def initialize(x,y) # @x = x # @y = y # end # end NUM = 10_000_000 Benchmark.bm(60) do |b| b.report("array") do NUM.times do it = [4,6] it[0] = 1 it[1] = 3 it[0] it[1] end end b.report("struct") do NUM.times do it = Point.new 4, 6 it.x = 1 it.y = 3 it.x it.y end end end
Version data entries
13 entries across 13 versions & 1 rubygems