Skip to content

Instantly share code, notes, and snippets.

@enebo
Created August 22, 2010 18:57
Show Gist options
  • Select an option

  • Save enebo/544134 to your computer and use it in GitHub Desktop.

Select an option

Save enebo/544134 to your computer and use it in GitHub Desktop.
class GCEvent < Struct.new(:name, :before, :after, :total, :time)
end
def tally(name)
$gc_events.inject(0) do |memo, event|
memo += event.time if event.name == name
memo
end
end
$gc_events = []
# Java 5/6 with -XX:+PrintGCDetails
# [GC [DefNew: 9536K->1149K(9536K), 0.0124713 secs] 11235K->4168K(31424K), 0.0125142 secs] [Times: user=0.01 sys=0.00, real=0.02 secs]
SIZE = '(\d+)([KM])'
BEFORE_AFTER_TOTAL = "#{SIZE}->#{SIZE}\\\(#{SIZE}\\\)"
GC = "GC\\\s+\\\[([^:]+):\\\s+#{BEFORE_AFTER_TOTAL}, #{TIME}"
while(line = $stdin.gets)
if line =~ /^\[(Full )?GC\s+\[([^:]+):\s+(\d+)([KM])->(\d+)([KM])\((\d+)([KM])\),\s+([\.\d]+)\s+secs\]\s+(\d+)([KM])->(\d+)([KM])\((\d+)([KM])\),\s+([\.\d]+)\s+secs\]/
$gc_events << GCEvent.new($2.to_sym, $3.to_i, $5.to_i, $7.to_i, $9.to_f)
$gc_events << GCEvent.new(:Entire, $10.to_i, $12.to_i, $14.to_i, $16.to_f)
end
end
puts "new: #{tally(:DefNew)}\ntotal: #{tally(:Entire)}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment