Class: GnCrossmap::Stats
- Inherits:
-
Object
- Object
- GnCrossmap::Stats
- Defined in:
- lib/gn_crossmap/stats.rb
Overview
Collects statistics about crossmapping process
Instance Attribute Summary collapse
-
#stats ⇒ Object
Returns the value of attribute stats.
Instance Method Summary collapse
-
#initialize ⇒ Stats
constructor
A new instance of Stats.
- #penalty(threads) ⇒ Object
- #update_eta(current_speed) ⇒ Object
Constructor Details
#initialize ⇒ Stats
Returns a new instance of Stats.
8 9 10 11 12 13 14 |
# File 'lib/gn_crossmap/stats.rb', line 8 def initialize @stats = { status: :init, total_records: 0, ingested_records: 0, ingestion_span: nil, ingestion_start: nil, resolution: eta_struct, matches: match_types, errors: [] } @smooth = 0.05 end |
Instance Attribute Details
#stats ⇒ Object
Returns the value of attribute stats.
6 7 8 |
# File 'lib/gn_crossmap/stats.rb', line 6 def stats @stats end |
Instance Method Details
#penalty(threads) ⇒ Object
16 17 18 19 |
# File 'lib/gn_crossmap/stats.rb', line 16 def penalty(threads) pnlt = 0.7 penalty_adj(threads.to_i, 1, pnlt) end |
#update_eta(current_speed) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/gn_crossmap/stats.rb', line 21 def update_eta(current_speed) eta = @stats[:resolution] eta[:speed] = current_speed if eta[:speed].nil? eta[:speed] = eta[:speed] * (1 - @smooth) + current_speed * @smooth eta[:eta] = (@stats[:total_records] - @stats[:resolution][:completed_records]) / eta[:speed] end |