Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Find out ruby string generation
require 'pp'
def profile
old_strs = ObjectSpace.count_objects[:T_STRING]
old_objs = GC.stat[:total_allocated_objects]
yield.tap do
new_strs = ObjectSpace.count_objects[:T_STRING]
new_objs = GC.stat[:total_allocated_objects]
puts <<-STR
Total allocated objects: #{new_objs - old_objs}
Total strings: #{new_strs - old_strs}
STR
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.