4 # ruby -Itools -rtracer blah.rb > spec/profiles/blah.yaml
18 # @counts[klass][method] += 1
19 @counts = Hash.new { |h,k| h[k] = Hash.new 0 }
23 set_trace_func method(:trace_func).to_proc
36 # @counts["klass[.|#]"] = [methods]
37 counts = Hash.new { |h,k| h[k] = [] }
39 @counts.each do |klass, methods|
40 pim = klass.public_instance_methods(false).map { |s| s.to_sym }
41 methods.each do |method, _|
42 name = if pim.include? method then
47 counts[name] << method
54 def trace_func(event, file, line, id, binding, klass, *)
55 return if file == __FILE__
56 return unless EVENT_SYMBOL[event.to_sym]
57 return if klass.nil? or id.nil?
59 saved_crit = Thread.critical
60 Thread.critical = true
62 @counts[klass][id] += 1
64 Thread.critical = saved_crit
84 elsif caller(0).size == 1