Skip to content

Commit

Permalink
added count_object function.
Browse files Browse the repository at this point in the history
  • Loading branch information
authorNari committed Dec 3, 2008
1 parent a654042 commit 1510047
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions lib/gc_profiler_on_graph.rb
Expand Up @@ -21,25 +21,36 @@ def self.insert_graphs
<script type="text/javascript">
window.onload = function() {
var heap_graph = new html5jp.graph.vbar("heap_vbar");
if( ! heap_graph ) { return; }
if(!heap_graph ) { return; }
#{display_draw_heap_params(profile)}
heap_graph.draw(items, params);
var gctime_graph = new html5jp.graph.line("gctime_line");
if( ! gctime_graph ) { return; }
if(!gctime_graph ) { return; }
#{display_draw_gctime_params(profile)}
gctime_graph.draw(items, params);
var stats_graph = new html5jp.graph.vbar("stats_vbar");
if(!stats_graph ) { return; }
#{display_draw_heap_stats_params}
stats_graph.draw(items, params);
};
</script>
HTML
canvas_html = <<-HTML
<table><tr>
<td><div><canvas width="600" height="500" id="heap_vbar"></canvas></div></td>
<td><div><canvas width="600" height="500" id="gctime_line"></canvas></div></td>
<td colspan="3"><div><canvas width="1300" height="400" id="stats_vbar"></canvas></div></td>
</tr><tr>
<td><div><canvas width="500" height="400" id="heap_vbar"></canvas></div></td>
<td><div><canvas width="500" height="400" id="gctime_line"></canvas></div></td>
<td></td>
</tr></table>
HTML
insert_text :before, /<\/head>/i, script_html
Expand Down Expand Up @@ -77,6 +88,13 @@ def self.display_draw_gctime_params(profile)
res += template_xy("['count', #{profile[:index].join(', ')}]", "['time(msec)']")
end

def self.display_draw_heap_stats_params
res = []
stats = ObjectSpace.count_objects.reject!{|k, v| %w(TOTAL FREE).include? k.to_s }.sort_by{|e| e[1]}
res = template_items "['object count', #{stats.map{|k,v| v}.join(', ')}]"
res += template_xy(%Q!['type', "#{stats.map{|k, v| k}.join('", "')}"]!, "['object count']")
end

def self.template_items(cols)
res = <<-HTML
var items = [
Expand Down

0 comments on commit 1510047

Please sign in to comment.