Skip to content

Instantly share code, notes, and snippets.

@SamSaffron
Last active July 31, 2017 03:50
Show Gist options
  • Save SamSaffron/f43996d5989cefbfbf69e9557ef13b23 to your computer and use it in GitHub Desktop.
Save SamSaffron/f43996d5989cefbfbf69e9557ef13b23 to your computer and use it in GitHub Desktop.
i = 0
def parse_param(s)
unless block_given?
return enum_for(__method__, s)
end
yield "a"
nil
end
def parse_line(line)
parts = parse_param(';' + line)
parts.next
end
while i < 10_000
Thread.new { parse_line("Content-Type:application/json; charset=ISO-8859-1") }.join
slots = GC.stat[:heap_live_slots]
_,rss = `ps ax -o pid,rss | grep -E "^[[:space:]]*#{$$}"`.strip.split.map(&:to_i)
puts "slots #{slots} #{i+=1} threads #{Thread.list.count} rss #{rss}"
end
puts "done #{RUBY_VERSION}"
gets
##
# Ruby 2.3.3
# slots 19183, rss 36980
# Ruby 2.4.1
# slots 14448, rss 132572
#
# Ruby latest
# slots 13783 rss 257108
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment