1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/benchmark/constant_invalidation.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
566 B
Ruby
Raw Normal View History

$VERBOSE = nil
CONSTANT1 = 1
CONSTANT2 = 1
CONSTANT3 = 1
CONSTANT4 = 1
CONSTANT5 = 1
def constants
[CONSTANT1, CONSTANT2, CONSTANT3, CONSTANT4, CONSTANT5]
end
500_000.times do
constants
# With previous behavior, this would cause all of the constant caches
# associated with the constant lookups listed above to invalidate, meaning
# they would all have to be fetched again. With current behavior, it only
# invalidates when a name matches, so the following constant set shouldn't
# impact the constant lookups listed above.
INVALIDATE = true
end