1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/benchmark/ivar_extend.yml
Aaron Patterson 9a6226c61e Eagerly allocate instance variable tables along with object
This allows us to allocate the right size for the object in advance,
meaning that we don't have to pay the cost of ivar table extension
later.  The idea is that if an object type ever became "extended" at
some point, then it is very likely it will become extended again.  So we
may as well allocate the ivar table up front.
2021-05-03 14:11:48 -07:00

23 lines
313 B
YAML

prelude: |
class Embedded
def initialize
@a = 1
@b = 1
@c = 1
end
end
class Extended
def initialize
@a = 1
@b = 1
@c = 1
@d = 1
@e = 1
@f = 1
end
end
benchmark:
embedded: Embedded.new
extended: Extended.new
loop_count: 20_000_000