Class: RuntimeProfiler::TextReport

Inherits:
Object
  • Object
show all
Defined in:
lib/runtime_profiler/text_report.rb

Constant Summary collapse

COUNT_WIDTH =
5
DURATION_WIDTH =
22
TOTAL_RUNTIME_WIDTH =
20
SUMMARY_TEMPLATE =
<<-EOT.strip_heredoc

  \e[1mPROFILING REPORT\e[22m
  ----------------

  \e[1mRUNTIME\e[22m
    Total Runtime     : %s ms
    Database Runtime  : %s ms
    View Runtime      : %s ms

  \e[1mMETHODS\e[22m
    SLOWEST           : %s (%s ms)
    MOSTLY CALLED     : %s (%s number of calls in %s ms)

  \e[1mSQL CALLS\e[22m
    Total             : %s
    Total Unique      : %s
    
    \e[1mSLOWEST\e[22m
      Total Runtime   : %s ms
      SQL             : %s
      Source          : %s
    
    \e[1mMOSTLY CALLED\e[22m
      Total Calls     : %s
      Total Runtime   : %s ms
      SQL             : %s
      Sources         : %s

EOT

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json_file, options) ⇒ TextReport

Returns a new instance of TextReport.



44
45
46
47
# File 'lib/runtime_profiler/text_report.rb', line 44

def initialize(json_file, options)
  self.data = JSON.parse( File.read(json_file) )
  self.options  = options
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



42
43
44
# File 'lib/runtime_profiler/text_report.rb', line 42

def data
  @data
end

#optionsObject

Returns the value of attribute options.



42
43
44
# File 'lib/runtime_profiler/text_report.rb', line 42

def options
  @options
end

Instance Method Details



49
50
51
52
53
54
55
56
# File 'lib/runtime_profiler/text_report.rb', line 49

def print
  print_summary

  if self.options.details == 'full'
    print_instrumented_methods
    print_instrumented_sql_calls
  end
end