Class: GnCrossmap::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/gn_crossmap/stats.rb

Overview

Collects statistics about crossmapping process

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStats

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

#statsObject

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