0
我正在運行一個ruby腳本並試圖查看它的GC統計信息,但輸出只是空字符串。這裏是我的腳本的內容:Ruby GC :: Profiler沒有輸出
$ ruby number_pool.rb
1855532
我期望看到來自GC報告標準了一些東西:
class NumberPool
...
attr_accessor :sets
def initialize
@sets = []
end
def allocate
allocated_number = Random.rand(min_bound..max_bound)
sets.each do |set|
next unless set.range.include?(allocated_number)
return set.range.delete(allocated_number)
end
factor = allocated_number/batch_size
min = factor * batch_size
max = min + batch_size
sub = SubPool.new(min, max)
sub.range.delete(allocated_number)
sets.push(sub)
allocated_number
end
...
def run_test
GC::Profiler.enable
a = NumberPool.new
p a.allocate
GC::Profiler.report
end
puts run_test
當我運行此,輸出。