Class: Silhouette::EntryPointProfiler
- Inherits:
-
DefaultProfiler
- Object
- Processor
- DefaultProfiler
- Silhouette::EntryPointProfiler
- Defined in:
- lib/silhouette/processor.rb
Instance Attribute Summary
Attributes inherited from DefaultProfiler
Instance Method Summary collapse
-
#initialize(file, sig, depth = nil) ⇒ EntryPointProfiler
constructor
A new instance of EntryPointProfiler.
- #print(f = STDERR, max = nil) ⇒ Object
- #process_call(thread, klass, kind, method, time) ⇒ Object
- #process_return(thread, klass, kind, method, time) ⇒ Object
Methods inherited from DefaultProfiler
#collapse_children, #data, #data=, #get_name, #print_flat_profile, #print_tree_profile, #process_end, #process_file, #process_method, #process_start, #save, #show_callers, #stack, #total_seconds
Methods inherited from Processor
#process_end, #process_file, #process_line, #process_method, #process_start, #run
Constructor Details
#initialize(file, sig, depth = nil) ⇒ EntryPointProfiler
Returns a new instance of EntryPointProfiler.
327 328 329 330 331 332 333 |
# File 'lib/silhouette/processor.rb', line 327 def initialize(file, sig, depth=nil) super(file) @entry = sig @start = Hash.new { |h,k| h[k] = false } @max_depth = depth @depth = Hash.new { |h,k| h[k] = 0 } end |
Instance Method Details
#print(f = STDERR, max = nil) ⇒ Object
373 374 375 376 377 378 379 380 |
# File 'lib/silhouette/processor.rb', line 373 def print(f=STDERR,max=nil) f.puts "Calls only shown if performed from #{@entry}." if @max_depth f.puts "Calls only processed #{@max_depth} level(s) deep." end f.puts super end |
#process_call(thread, klass, kind, method, time) ⇒ Object
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/silhouette/processor.rb', line 335 def process_call(thread, klass, kind, method, time) #return unless thread == "b7533c3c" if @entry == [klass, kind, method].to_s @start[thread] = true STDERR.puts "entered #{@entry} at #{time} in #{thread}" return end return unless @start[thread] # puts "#{[klass, kind, method]} (#{@depth[thread]})" @depth[thread] += 1 #puts "call" #p @depth return if @max_depth and @depth[thread] > @max_depth # puts "call: #{@depth} #{[klass, kind, method]}" super end |
#process_return(thread, klass, kind, method, time) ⇒ Object
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'lib/silhouette/processor.rb', line 356 def process_return(thread, klass, kind, method, time) #return unless thread == "b7533c3c" if @entry == [klass, kind, method].to_s @start[thread] = false STDERR.puts "exitted #{@entry} at #{time} in #{thread}" return end return unless @start[thread] if !@max_depth or @depth[thread] <= @max_depth super end @depth[thread] -= 1 end |