mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
9a6226c61e
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.
23 lines
313 B
YAML
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
|