Improvements to ruby's autodocumentation.
GC.start was failing when ruby was run without verbose warnings. Fixed. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9752 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ec4daa8b0e
commit
75f1af27a5
3 changed files with 37 additions and 36 deletions
|
|
@ -30,44 +30,41 @@
|
|||
# License:: Ruby
|
||||
#
|
||||
|
||||
if $VERBOSE
|
||||
module GC
|
||||
module GC
|
||||
|
||||
class << self
|
||||
class << self
|
||||
|
||||
attr :last_stat
|
||||
attr_accessor :track_class
|
||||
attr :last_stat
|
||||
attr_accessor :track_class
|
||||
|
||||
alias :_start :start
|
||||
|
||||
def start
|
||||
_start
|
||||
stats
|
||||
end
|
||||
|
||||
def stats
|
||||
stats = Hash.new(0)
|
||||
ObjectSpace.each_object {|o| stats[o.class] += 1}
|
||||
|
||||
if track_class
|
||||
v = stats[track_class]
|
||||
printf "\t%-30s %10d", track_class.to_s, v
|
||||
if last_stat
|
||||
printf " | delta %10d", (v - last_stat[track_class])
|
||||
end
|
||||
puts
|
||||
else
|
||||
stats.sort {|(k1,v1),(k2,v2)| v2 <=> v1}.each do |k,v|
|
||||
printf "\t%-30s %10d", k, v
|
||||
printf " | delta %10d", (v - last_stat[k]) if last_stat
|
||||
puts
|
||||
end
|
||||
end
|
||||
|
||||
last_stat = stats
|
||||
end
|
||||
alias :_start :start
|
||||
|
||||
def start
|
||||
_start
|
||||
stats if $VERBOSE
|
||||
end
|
||||
|
||||
def stats
|
||||
stats = Hash.new(0)
|
||||
ObjectSpace.each_object {|o| stats[o.class] += 1}
|
||||
|
||||
if track_class
|
||||
v = stats[track_class]
|
||||
printf "\t%-30s %10d", track_class.to_s, v
|
||||
if last_stat
|
||||
printf " | delta %10d", (v - last_stat[track_class])
|
||||
end
|
||||
puts
|
||||
else
|
||||
stats.sort {|(k1,v1),(k2,v2)| v2 <=> v1}.each do |k,v|
|
||||
printf "\t%-30s %10d", k, v
|
||||
printf " | delta %10d", (v - last_stat[k]) if last_stat
|
||||
puts
|
||||
end
|
||||
end
|
||||
|
||||
last_stat = stats
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue