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.
21 22 23 24 25 |
# File 'lib/origen/application/statistics.rb', line 21 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
[View source]
128 129 130 |
# File 'lib/origen/application/statistics.rb', line 128 def add_cycle(x = 1) current_pattern.cycles += x end |
#add_time_in_ns(x) ⇒ Object
[View source]
132 133 134 |
# File 'lib/origen/application/statistics.rb', line 132 def add_time_in_ns(x) current_pattern.duration += x end |
#add_vector(x = 1) ⇒ Object
[View source]
124 125 126 |
# File 'lib/origen/application/statistics.rb', line 124 def add_vector(x = 1) current_pattern.vectors += x end |
#clean_run? ⇒ Boolean
109 110 111 112 113 114 |
# File 'lib/origen/application/statistics.rb', line 109 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
[View source]
136 137 138 139 140 |
# File 'lib/origen/application/statistics.rb', line 136 def collect_for_pattern(key) @pattern_key = key yield @pattern_key = nil end |
#current_pattern ⇒ Object
[View source]
142 143 144 |
# File 'lib/origen/application/statistics.rb', line 142 def current_pattern pattern(@pattern_key) end |
#execution_time_for(key) ⇒ Object
[View source]
158 159 160 |
# File 'lib/origen/application/statistics.rb', line 158 def execution_time_for(key) pattern(key).duration.to_f / 1_000_000_000 end |
#number_of_cycles_for(key) ⇒ Object
[View source]
154 155 156 |
# File 'lib/origen/application/statistics.rb', line 154 def number_of_cycles_for(key) pattern(key).vectors end |
#number_of_vectors_for(key) ⇒ Object
[View source]
150 151 152 |
# File 'lib/origen/application/statistics.rb', line 150 def number_of_vectors_for(key) pattern(key).vectors end |
#pattern(key) ⇒ Object
[View source]
146 147 148 |
# File 'lib/origen/application/statistics.rb', line 146 def pattern(key) @patterns[key] ||= Pattern.new end |
#print_summary ⇒ Object
[View source]
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 91 |
# File 'lib/origen/application/statistics.rb', line 50 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
[View source]
116 117 118 |
# File 'lib/origen/application/statistics.rb', line 116 def record_failed_pattern @failed_patterns += 1 end |
#record_missing_pattern ⇒ Object
[View source]
120 121 122 |
# File 'lib/origen/application/statistics.rb', line 120 def record_missing_pattern @missing_patterns += 1 end |
#record_pattern_completion(key) ⇒ Object
[View source]
162 163 164 165 166 167 |
# File 'lib/origen/application/statistics.rb', line 162 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
[View source]
180 181 182 183 184 185 186 187 188 189 |
# File 'lib/origen/application/statistics.rb', line 180 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
[View source]
169 170 171 172 173 174 175 176 177 178 |
# File 'lib/origen/application/statistics.rb', line 169 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
[View source]
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/origen/application/statistics.rb', line 27 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
[View source]
47 48 |
# File 'lib/origen/application/statistics.rb', line 47 def reset_pattern_stats end |
#summary_text ⇒ Object
[View source]
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/origen/application/statistics.rb', line 93 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 |