Class: MwrapRack::HeapPages
- Inherits:
-
Object
- Object
- MwrapRack::HeapPages
- Includes:
- HtmlResponse
- Defined in:
- lib/mwrap_rack.rb
Overview
:nodoc:
Constant Summary collapse
- HEADER =
'<tr><th>address</th><th>generation</th></tr>'
- GC_STAT_URL =
'https://docs.ruby-lang.org/en/trunk/GC.html#method-c-stat'
- GC_STAT_HELP =
<<~EOM <p>Non-Infinity lifespans can indicate fragmentation. <p>See <a href="#{GC_STAT_URL}">#{GC_STAT_URL}</a> for info on GC.stat values. EOM
Instance Method Summary collapse
Methods included from HtmlResponse
Instance Method Details
#each ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/mwrap_rack.rb', line 121 def each Mwrap.quiet do yield("<html><head><title>heap pages</title></head>" \ "<body><h1>heap pages</h1>" \ "<table><tr><th>stat</th><th>value</th></tr>\n" \ "#{hpb_rows}" \ "#{gc_stat_rows}" \ "</table>\n" \ "#{GC_STAT_HELP}" \ "<table>#{HEADER}") Mwrap::HeapPageBody.each do |addr, generation| addr = -sprintf('0x%x', addr) yield(-"<tr><td>#{addr}</td><td>#{generation}</td></tr>\n") end yield "</table></body></html>\n" end end |
#gc_stat_rows ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/mwrap_rack.rb', line 106 def gc_stat_rows GC.stat(stat = Thread.current[:mwrap_gc_stat] ||= {}) %i(count heap_allocated_pages heap_eden_pages heap_tomb_pages total_allocated_pages total_freed_pages).map do |k| "<tr><td>GC.stat(:#{k})</td><td>#{stat[k]}</td></tr>\n" end.join end |
#hpb_rows ⇒ Object
96 97 98 99 100 101 102 103 104 |
# File 'lib/mwrap_rack.rb', line 96 def hpb_rows Mwrap::HeapPageBody.stat(stat = Thread.current[:mwrap_hpb_stat] ||= {}) %i(lifespan_max lifespan_min lifespan_mean lifespan_stddev deathspan_max deathspan_min deathspan_mean deathspan_stddev resurrects ).map! do |k| "<tr><td>#{k}</td><td>#{stat[k]}</td></tr>\n" end.join end |