Class: Origen::Application::Statistics
- Defined in:
- lib/origen/application/statistics.rb
Overview
Responsible for keeping track of all stats collected during a run
Defined Under Namespace
Classes: Pattern
Instance Attribute Summary collapse
-
#changed_files ⇒ Object
Returns the value of attribute changed_files.
-
#changed_patterns ⇒ Object
Returns the value of attribute changed_patterns.
-
#completed_files ⇒ Object
Returns the value of attribute completed_files.
-
#completed_patterns ⇒ Object
Returns the value of attribute completed_patterns.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#failed_files ⇒ Object
Returns the value of attribute failed_files.
-
#failed_patterns ⇒ Object
Returns the value of attribute failed_patterns.
-
#missing_files ⇒ Object
Returns the value of attribute missing_files.
-
#missing_patterns ⇒ Object
Returns the value of attribute missing_patterns.
-
#new_files ⇒ Object
Returns the value of attribute new_files.
-
#new_patterns ⇒ Object
Returns the value of attribute new_patterns.
-
#total_cycles ⇒ Object
Returns the value of attribute total_cycles.
-
#total_duration ⇒ Object
Returns the value of attribute total_duration.
-
#total_vectors ⇒ Object
Returns the value of attribute total_vectors.
Instance Method Summary collapse
- #add_cycle(x = 1) ⇒ Object
- #add_time_in_ns(x) ⇒ Object
- #add_vector(x = 1) ⇒ Object
- #clean_run? ⇒ Boolean
- #collect_for_pattern(key) ⇒ Object
- #current_pattern ⇒ Object
- #execution_time_for(key) ⇒ Object
-
#initialize(options) ⇒ Statistics
constructor
A new instance of Statistics.
- #number_of_cycles_for(key) ⇒ Object
- #number_of_vectors_for(key) ⇒ Object
- #pattern(key) ⇒ Object
- #print_summary ⇒ Object
- #record_failed_pattern ⇒ Object
- #record_missing_pattern ⇒ Object
- #record_pattern_completion(key) ⇒ Object
- #report_fail ⇒ Object
- #report_pass ⇒ Object
- #reset_global_stats ⇒ Object
- #reset_pattern_stats ⇒ Object
- #summary_text ⇒ Object
Constructor Details
#initialize(options) ⇒ Statistics
Returns a new instance of Statistics.
20 21 22 23 24 |
# File 'lib/origen/application/statistics.rb', line 20 def initialize() @options = @patterns = {} reset_global_stats end |
Instance Attribute Details
#changed_files ⇒ Object
Returns the value of attribute changed_files.
5 6 7 |
# File 'lib/origen/application/statistics.rb', line 5 def changed_files @changed_files end |
#changed_patterns ⇒ Object
Returns the value of attribute changed_patterns.
7 8 9 |
# File 'lib/origen/application/statistics.rb', line 7 def changed_patterns @changed_patterns end |
#completed_files ⇒ Object
Returns the value of attribute completed_files.
5 6 7 |
# File 'lib/origen/application/statistics.rb', line 5 def completed_files @completed_files end |
#completed_patterns ⇒ Object
Returns the value of attribute completed_patterns.
7 8 9 |
# File 'lib/origen/application/statistics.rb', line 7 def completed_patterns @completed_patterns end |
#errors ⇒ Object
Returns the value of attribute errors.
9 10 11 |
# File 'lib/origen/application/statistics.rb', line 9 def errors @errors end |
#failed_files ⇒ Object
Returns the value of attribute failed_files.
5 6 7 |
# File 'lib/origen/application/statistics.rb', line 5 def failed_files @failed_files end |
#failed_patterns ⇒ Object
Returns the value of attribute failed_patterns.
7 8 9 |
# File 'lib/origen/application/statistics.rb', line 7 def failed_patterns @failed_patterns end |
#missing_files ⇒ Object
Returns the value of attribute missing_files.
5 6 7 |
# File 'lib/origen/application/statistics.rb', line 5 def missing_files @missing_files end |
#missing_patterns ⇒ Object
Returns the value of attribute missing_patterns.
7 8 9 |
# File 'lib/origen/application/statistics.rb', line 7 def missing_patterns @missing_patterns end |
#new_files ⇒ Object
Returns the value of attribute new_files.
5 6 7 |
# File 'lib/origen/application/statistics.rb', line 5 def new_files @new_files end |
#new_patterns ⇒ Object
Returns the value of attribute new_patterns.
7 8 9 |
# File 'lib/origen/application/statistics.rb', line 7 def new_patterns @new_patterns end |
#total_cycles ⇒ Object
Returns the value of attribute total_cycles.
9 10 11 |
# File 'lib/origen/application/statistics.rb', line 9 def total_cycles @total_cycles end |
#total_duration ⇒ Object
Returns the value of attribute total_duration.
9 10 11 |
# File 'lib/origen/application/statistics.rb', line 9 def total_duration @total_duration end |
#total_vectors ⇒ Object
Returns the value of attribute total_vectors.
9 10 11 |
# File 'lib/origen/application/statistics.rb', line 9 def total_vectors @total_vectors end |
Instance Method Details
#add_cycle(x = 1) ⇒ Object
127 128 129 |
# File 'lib/origen/application/statistics.rb', line 127 def add_cycle(x = 1) current_pattern.cycles += x end |
#add_time_in_ns(x) ⇒ Object
131 132 133 |
# File 'lib/origen/application/statistics.rb', line 131 def add_time_in_ns(x) current_pattern.duration += x end |
#add_vector(x = 1) ⇒ Object
123 124 125 |
# File 'lib/origen/application/statistics.rb', line 123 def add_vector(x = 1) current_pattern.vectors += x end |
#clean_run? ⇒ Boolean
108 109 110 111 112 113 |
# File 'lib/origen/application/statistics.rb', line 108 def clean_run? @changed_files == 0 && @changed_patterns == 0 && @new_files == 0 && @new_patterns == 0 && @failed_files == 0 && @failed_patterns == 0 && @errors == 0 end |
#collect_for_pattern(key) ⇒ Object
135 136 137 138 139 |
# File 'lib/origen/application/statistics.rb', line 135 def collect_for_pattern(key) @pattern_key = key yield @pattern_key = nil end |
#current_pattern ⇒ Object
141 142 143 |
# File 'lib/origen/application/statistics.rb', line 141 def current_pattern pattern(@pattern_key) end |
#execution_time_for(key) ⇒ Object
157 158 159 |
# File 'lib/origen/application/statistics.rb', line 157 def execution_time_for(key) pattern(key).duration.to_f / 1_000_000_000 end |
#number_of_cycles_for(key) ⇒ Object
153 154 155 |
# File 'lib/origen/application/statistics.rb', line 153 def number_of_cycles_for(key) pattern(key).vectors end |
#number_of_vectors_for(key) ⇒ Object
149 150 151 |
# File 'lib/origen/application/statistics.rb', line 149 def number_of_vectors_for(key) pattern(key).vectors end |
#pattern(key) ⇒ Object
145 146 147 |
# File 'lib/origen/application/statistics.rb', line 145 def pattern(key) @patterns[key] ||= Pattern.new end |
#print_summary ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/origen/application/statistics.rb', line 49 def print_summary method = clean_run? ? :success : :info if @completed_patterns > 0 || @failed_patterns > 0 Origen.log.send method, "Total patterns: #{@completed_patterns}" Origen.log.send method, "Total vectors: #{@total_vectors}" Origen.log.send method, 'Total duration: %.6f' % @total_duration Origen.log.send method, "New patterns: #{@new_patterns}" if @changed_patterns > 0 Origen.log.warn "Changed patterns: #{@changed_patterns}" else Origen.log.send method, "Changed patterns: #{@changed_patterns}" end Origen.log.error "FAILED patterns: #{@failed_patterns}" if @failed_patterns > 0 Origen.log.info end if @completed_files > 0 || @failed_files > 0 Origen.log.send method, "Total files: #{@completed_files}" Origen.log.send method, "New files: #{@new_files}" Origen.log.send method, "Changed files: #{@changed_files}" Origen.log.error "FAILED files: #{@failed_files}" if @failed_files > 0 Origen.log.info end if @errors > 0 Origen.log.error "ERRORS: #{@errors}" end if @changed_files > 0 || @changed_patterns > 0 changes = true Origen.log.info 'To accept all of these changes run:' Origen.log.info ' origen save changed' end if @new_files > 0 || @new_patterns > 0 news = true Origen.log.info 'To save all of these new files as the reference version run:' Origen.log.info ' origen save new' end if changes && news Origen.log.info 'To save both new and changed files run:' Origen.log.info ' origen save all' end Origen.log.info '**********************************************************************' end |
#record_failed_pattern ⇒ Object
115 116 117 |
# File 'lib/origen/application/statistics.rb', line 115 def record_failed_pattern @failed_patterns += 1 end |
#record_missing_pattern ⇒ Object
119 120 121 |
# File 'lib/origen/application/statistics.rb', line 119 def record_missing_pattern @missing_patterns += 1 end |
#record_pattern_completion(key) ⇒ Object
161 162 163 164 165 166 |
# File 'lib/origen/application/statistics.rb', line 161 def record_pattern_completion(key) @completed_patterns += 1 @total_vectors += number_of_vectors_for(key) @total_cycles += number_of_cycles_for(key) @total_duration += execution_time_for(key) end |
#report_fail ⇒ Object
179 180 181 182 183 184 185 186 187 188 |
# File 'lib/origen/application/statistics.rb', line 179 def report_fail Origen.log.error '' Origen.log.error ' FFFFFF AA II LL' Origen.log.error ' FF AAAA II LL' Origen.log.error ' FFFFF AA AA II LL' Origen.log.error ' FF AAAAAAAA II LL' Origen.log.error ' FF AA AA II LL' Origen.log.error ' FF AA AA II LLLLLL' Origen.log.error '' end |
#report_pass ⇒ Object
168 169 170 171 172 173 174 175 176 177 |
# File 'lib/origen/application/statistics.rb', line 168 def report_pass Origen.log.success '' Origen.log.success ' PPPPP AA SSSS SSSS' Origen.log.success ' PP PP AAAA SS SS SS SS' Origen.log.success ' PPPPP AA AA SS SS' Origen.log.success ' PP AAAAAAAA SS SS' Origen.log.success ' PP AA AA SS SS SS SS' Origen.log.success ' PP AA AA SSSS SSSS' Origen.log.success '' end |
#reset_global_stats ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/origen/application/statistics.rb', line 26 def reset_global_stats @completed_files = 0 @failed_files = 0 @missing_files = 0 @new_files = 0 @changed_files = 0 @completed_patterns = 0 @failed_patterns = 0 @missing_patterns = 0 @new_patterns = 0 @changed_patterns = 0 @total_vectors = 0 @total_cycles = 0 @total_duration = 0 @errors = 0 end |
#reset_pattern_stats ⇒ Object
46 47 |
# File 'lib/origen/application/statistics.rb', line 46 def reset_pattern_stats end |
#summary_text ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/origen/application/statistics.rb', line 92 def summary_text <<-END Total patterns: #{@completed_patterns} New patterns: #{@new_patterns} Changed patterns: #{@changed_patterns} FAILED patterns: #{@failed_patterns} Total files: #{@completed_files} New files: #{@new_files} Changed files: #{@changed_files} FAILED files: #{@failed_files} ERRORS: #{@errors} END end |