Made GC.stats report things only in verbose mode.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9717 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
18a6b82541
commit
ca5f54f668
1 changed files with 4 additions and 2 deletions
|
|
@ -14,17 +14,19 @@
|
|||
module GC
|
||||
@@last_stat = nil
|
||||
def self.stats(klass = nil)
|
||||
return unless $VERBOSE
|
||||
|
||||
stats = Hash.new(0)
|
||||
ObjectSpace.each_object {|o| stats[o.class] += 1}
|
||||
|
||||
if klass
|
||||
v = stats[klass]
|
||||
printf "%-30s %10d", klass.to_s, v
|
||||
printf "\t%-30s %10d", klass.to_s, v
|
||||
printf " | delta %10d", (v - @@last_stat[klass]) if @@last_stat
|
||||
puts
|
||||
else
|
||||
stats.sort {|(k1,v1),(k2,v2)| v2 <=> v1}.each do |k,v|
|
||||
printf "%-30s %10d", k, v
|
||||
printf "\t%-30s %10d", k, v
|
||||
printf " | delta %10d", (v - @@last_stat[k]) if @@last_stat
|
||||
puts
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue