Class: Perf::ReportFormatHtml
- Inherits:
-
ReportFormat
- Object
- ReportFormat
- Perf::ReportFormatHtml
- Defined in:
- lib/perf/report_format_html.rb
Constant Summary collapse
- PERCENT_FORMAT =
default for :time_format
"%.2f"
- TIME_FORMAT =
default for :percent_format
"%.7f"
- COUNT_FORMAT =
default for :count_format
"%d"
- INDENT =
default for :indent_string
" "*3
Constants inherited from ReportFormat
Perf::ReportFormat::ACCURACY_DESCRIPTION, Perf::ReportFormat::MAX_ACCURACY_SIZE, Perf::ReportFormat::MIN_TOTAL_TIME
Instance Method Summary collapse
-
#format(perf, options = {}) ⇒ Object
Example.
- #format_footer(v) ⇒ Object
-
#format_header(v) ⇒ Object
Formats the header.
-
#format_measure(v) ⇒ Object
Formats the measure.
- #format_title(what, options) ⇒ Object
-
#initialize ⇒ ReportFormatHtml
constructor
A new instance of ReportFormatHtml.
Methods inherited from ReportFormat
Constructor Details
#initialize ⇒ ReportFormatHtml
Returns a new instance of ReportFormatHtml.
12 13 14 15 |
# File 'lib/perf/report_format_html.rb', line 12 def initialize super @line=0 end |
Instance Method Details
#format(perf, options = {}) ⇒ Object
Example
m=Perf::Meter.new m.measure(:something) { something } m.report_html()
83 84 85 86 87 88 89 90 |
# File 'lib/perf/report_format_html.rb', line 83 def format(perf,={}) ||={} @time_format = [:time_format] || TIME_FORMAT @percent_format = [:percent_format] || PERCENT_FORMAT @count_format = [:count_format] || COUNT_FORMAT @indent_string = [:indent_string] || INDENT super end |
#format_footer(v) ⇒ Object
122 123 124 |
# File 'lib/perf/report_format_html.rb', line 122 def (v) "</table>" end |
#format_header(v) ⇒ Object
Formats the header
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/perf/report_format_html.rb', line 93 def format_header(v) "<table class='rubyperf_report'><tr>" \ "<th class='title'>#{v[:title]}</th>" \ "<th class='percent'>%</th>" \ "<th class='accuracy'>accuracy</th>" \ "<th class='count'>count</th>" \ "<th class='user_time'>user</th>" \ "<th class='system_time'>system</th>" \ "<th class='total_time'>total</th>" \ "<th class='real_time'>real</th>" \ "</tr>" end |
#format_measure(v) ⇒ Object
Formats the measure
107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/perf/report_format_html.rb', line 107 def format_measure(v) @line+=1 percent= v[:percent].is_a?(String) ? v[:percent] : (@percent_format % v[:percent]) "<tr class='#{@line % 2==0 ? "even_row" : "odd_row"}'>" \ "<td class='title'>#{v[:title]}</td>" \ "<td class='percent'>#{percent}</td>" \ "<td class='accuracy'>#{v[:accuracy]}</td>" \ "<td class='count'>#{@count_format % v[:count]}</td>" \ "<td class='user_time'>#{@time_format % v[:time].utime}</td>" \ "<td class='system_time'>#{@time_format % v[:time].stime}</td>" \ "<td class='total_time'>#{@time_format % v[:time].total}</td>" \ "<td class='real_time'>#{@time_format % v[:time].real}</td>" \ "</tr>" end |
#format_title(what, options) ⇒ Object
126 127 128 129 |
# File 'lib/perf/report_format_html.rb', line 126 def format_title(what,) path=what.split("\\") "#{(path.size-2) ? @indent_string * (path.size-2) : ""}\\#{CGI.escapeHTML(path.last)}" end |