Class: Optimize::Log
- Inherits:
-
Object
- Object
- Optimize::Log
- Defined in:
- lib/optimize/log.rb
Defined Under Namespace
Classes: Entry
Instance Attribute Summary collapse
-
#convergence ⇒ Object
readonly
Returns the value of attribute convergence.
-
#rewrite_count ⇒ Object
readonly
Returns the value of attribute rewrite_count.
Instance Method Summary collapse
- #entries ⇒ Object
- #for_pass(pass) ⇒ Object
-
#initialize ⇒ Log
constructor
A new instance of Log.
- #record_convergence(function_key, iterations) ⇒ Object
-
#rewrite(pass:, reason:, file:, line:) ⇒ Object
An optimization site that actually rewrote IR.
-
#skip(pass:, reason:, file:, line:) ⇒ Object
An optimization site that declined to rewrite.
Constructor Details
#initialize ⇒ Log
Returns a new instance of Log.
7 8 9 10 11 |
# File 'lib/optimize/log.rb', line 7 def initialize @entries = [] @rewrite_count = 0 @convergence = {} end |
Instance Attribute Details
#convergence ⇒ Object (readonly)
Returns the value of attribute convergence.
17 18 19 |
# File 'lib/optimize/log.rb', line 17 def convergence @convergence end |
#rewrite_count ⇒ Object (readonly)
Returns the value of attribute rewrite_count.
17 18 19 |
# File 'lib/optimize/log.rb', line 17 def rewrite_count @rewrite_count end |
Instance Method Details
#entries ⇒ Object
13 14 15 |
# File 'lib/optimize/log.rb', line 13 def entries @entries.dup.freeze end |
#for_pass(pass) ⇒ Object
37 38 39 |
# File 'lib/optimize/log.rb', line 37 def for_pass(pass) @entries.select { |e| e.pass == pass } end |
#record_convergence(function_key, iterations) ⇒ Object
33 34 35 |
# File 'lib/optimize/log.rb', line 33 def record_convergence(function_key, iterations) @convergence[function_key] = iterations end |
#rewrite(pass:, reason:, file:, line:) ⇒ Object
An optimization site that actually rewrote IR. Feeds fixed-point termination via rewrite_count.
21 22 23 24 |
# File 'lib/optimize/log.rb', line 21 def rewrite(pass:, reason:, file:, line:) @entries << Entry.new(pass: pass, reason: reason, file: file, line: line) @rewrite_count += 1 end |
#skip(pass:, reason:, file:, line:) ⇒ Object
An optimization site that declined to rewrite. Does NOT count toward rewrite_count — fixed-point iteration must not treat a decline as a change.
29 30 31 |
# File 'lib/optimize/log.rb', line 29 def skip(pass:, reason:, file:, line:) @entries << Entry.new(pass: pass, reason: reason, file: file, line: line) end |