Class: Rcov::HTMLProfiling
- Inherits:
-
HTMLCoverage
- Object
- BaseFormatter
- HTMLCoverage
- Rcov::HTMLProfiling
- Defined in:
- lib/rcov/formatters/html_coverage.rb
Overview
:nodoc:
Constant Summary collapse
- DEFAULT_OPTS =
{:destdir => "profiling"}
Constants inherited from BaseFormatter
BaseFormatter::RCOV_IGNORE_REGEXPS
Instance Method Summary collapse
- #default_color ⇒ Object
- #default_title ⇒ Object
-
#initialize(opts = {}) ⇒ HTMLProfiling
constructor
A new instance of HTMLProfiling.
- #output_color_table? ⇒ Boolean
- #span_class(sourceinfo, marked, count) ⇒ Object
Methods inherited from HTMLCoverage
Methods inherited from BaseFormatter
#add_file, #code_coverage, #each_file_pair_sorted, #mangle_filename, #normalize_filename, #num_code_lines, #num_lines, #sorted_file_pairs, #total_coverage
Constructor Details
#initialize(opts = {}) ⇒ HTMLProfiling
Returns a new instance of HTMLProfiling.
124 125 126 127 128 129 |
# File 'lib/rcov/formatters/html_coverage.rb', line 124 def initialize(opts = {}) = DEFAULT_OPTS.clone.update(opts) super() @max_cache = {} @median_cache = {} end |
Instance Method Details
#default_color ⇒ Object
135 136 137 138 139 140 141 |
# File 'lib/rcov/formatters/html_coverage.rb', line 135 def default_color if @color "rgb(179,205,255)" else "rgb(255, 255, 255)" end end |
#default_title ⇒ Object
131 132 133 |
# File 'lib/rcov/formatters/html_coverage.rb', line 131 def default_title "Bogo-profile information" end |
#output_color_table? ⇒ Boolean
143 144 145 |
# File 'lib/rcov/formatters/html_coverage.rb', line 143 def output_color_table? false end |
#span_class(sourceinfo, marked, count) ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/rcov/formatters/html_coverage.rb', line 147 def span_class(sourceinfo, marked, count) full_scale_range = @fsr # dB nz_count = sourceinfo.counts.select{|x| x && x != 0} nz_count << 1 # avoid div by 0 max = @max_cache[sourceinfo] ||= nz_count.max #avg = @median_cache[sourceinfo] ||= 1.0 * # nz_count.inject{|a,b| a+b} / nz_count.size median = @median_cache[sourceinfo] ||= 1.0 * nz_count.sort[nz_count.size/2] max ||= 2 max = 2 if max == 1 if marked == true count = 1 if !count || count == 0 idx = 50 + 1.0 * (500/full_scale_range) * Math.log(count/median) / Math.log(10) idx = idx.to_i idx = 0 if idx < 0 idx = 100 if idx > 100 "run#{idx}" else nil end end |