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.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/active-profiling/ruby_profiler/output.rb', line 6 def initialize(*args) @options = Rails.application.config.active_profiling.profiler.merge(args.) @path = args.first @output = @options[:output] || case @options[:printer] when :call_tree, :call_stack, :graph_html, :dot :file else :log end end |
Instance Method Details
#run ⇒ Object
19 20 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 |
# File 'lib/active-profiling/ruby_profiler/output.rb', line 19 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 result = yield rescue StandardError exception = $ERROR_INFO end case @output when :stdout write_to_stdout when :log write_to_log when :file write_to_file_or_path end raise exception if exception result ensure GC.enable if @options[:disable_gc] end |