Class: ActiveProfiling::RubyProfiler::Output
- Inherits:
-
Object
- Object
- ActiveProfiling::RubyProfiler::Output
- Defined in:
- lib/active-profiling/ruby_profiler/output.rb
Instance Method Summary collapse
-
#initialize(*args) ⇒ Output
constructor
A new instance of Output.
- #run ⇒ Object
Constructor Details
#initialize(*args) ⇒ Output
Returns a new instance of Output.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/active-profiling/ruby_profiler/output.rb', line 5 def initialize(*args) @options = Rails.application.config.active_profiling.profiler.merge(args.) @path = args.first @output = if @options[:output] @options[:output] else case @options[:printer] when :call_tree, :call_stack, :graph_html, :dot :file else :log end end end |
Instance Method Details
#run ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/active-profiling/ruby_profiler/output.rb', line 21 def run return yield if @output == :log && !ActiveProfiling::ActionController::LogSubscriber.logger RubyProf.measure_mode = RubyProf.const_get(@options[:measure_mode].to_s.upcase) GC.disable if @options[:disable_gc] result = nil exception = nil @profiler_result = RubyProf.profile do begin result = yield rescue exception = $! end end case @output when :stdout write_to_stdout when :log write_to_log when :file write_to_file_or_path end if exception raise exception else result end ensure GC.enable if @options[:disable_gc] end |