Created
March 2, 2023 00:33
-
-
Save jhawthorn/e9db7a1443eaa957cef772dccdc14d9a 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
class A | |
def foo | |
@foo | |
end | |
def initialize | |
@foo = 123 | |
40.times do | |
instance_variable_set(:"@var_#{_1}", _1) | |
end | |
end | |
end | |
A.new # warm A's size pool | |
obj1 = A.new | |
obj2 = A.new.freeze | |
N = ENV.fetch("N", 10_000_000).to_i | |
N.times do | |
obj1.foo | |
obj2.foo | |
end |
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
class A | |
def foo | |
@foo | |
end | |
def initialize(bar = false) | |
@bar = 123 if bar | |
@foo = 123 | |
40.times do | |
instance_variable_set(:"@var_#{_1}", _1) | |
end | |
end | |
end | |
A.new # warm A's size pool | |
obj1 = A.new | |
obj2 = A.new(true) | |
N = ENV.fetch("N", 10_000_000).to_i | |
N.times do | |
obj1.foo | |
obj2.foo | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment