class Origen::Application::Statistics
Responsible for keeping track of all stats collected during a run
Attributes
changed_files[RW]
changed_patterns[RW]
completed_files[RW]
completed_patterns[RW]
errors[RW]
failed_files[RW]
failed_patterns[RW]
missing_files[RW]
missing_patterns[RW]
new_files[RW]
new_patterns[RW]
total_cycles[RW]
total_duration[RW]
total_vectors[RW]
Public Class Methods
new(options)
click to toggle source
# File lib/origen/application/statistics.rb, line 21 def initialize(options) @options = options @patterns = {} reset_global_stats end
Public Instance Methods
add_cycle(x = 1)
click to toggle source
# File lib/origen/application/statistics.rb, line 128 def add_cycle(x = 1) current_pattern.cycles += x end
add_time_in_ns(x)
click to toggle source
# File lib/origen/application/statistics.rb, line 132 def add_time_in_ns(x) current_pattern.duration += x end
add_vector(x = 1)
click to toggle source
# File lib/origen/application/statistics.rb, line 124 def add_vector(x = 1) current_pattern.vectors += x end
clean_run?()
click to toggle source
# 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) { || ... }
click to toggle source
# File lib/origen/application/statistics.rb, line 136 def collect_for_pattern(key) @pattern_key = key yield @pattern_key = nil end
current_pattern()
click to toggle source
# File lib/origen/application/statistics.rb, line 142 def current_pattern pattern(@pattern_key) end
execution_time_for(key)
click to toggle source
# 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)
click to toggle source
# File lib/origen/application/statistics.rb, line 154 def number_of_cycles_for(key) pattern(key).vectors end
number_of_vectors_for(key)
click to toggle source
# File lib/origen/application/statistics.rb, line 150 def number_of_vectors_for(key) pattern(key).vectors end
pattern(key)
click to toggle source
# File lib/origen/application/statistics.rb, line 146 def pattern(key) @patterns[key] ||= Pattern.new end
print_summary()
click to toggle source
# 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()
click to toggle source
# File lib/origen/application/statistics.rb, line 116 def record_failed_pattern @failed_patterns += 1 end
record_missing_pattern()
click to toggle source
# File lib/origen/application/statistics.rb, line 120 def record_missing_pattern @missing_patterns += 1 end
record_pattern_completion(key)
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# File lib/origen/application/statistics.rb, line 47 def reset_pattern_stats end
summary_text()
click to toggle source
# 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