Class: Greenroom::Recorder::Tally

Inherits:
Object
  • Object
show all
Defined in:
lib/greenroom/recorder.rb

Overview

A mutable set of counters for one experiment name. Kept separate from Recorder itself because a single run can, in principle, touch more than one experiment name (a misconfigured target, or a host that reuses one job for several experiments), and each needs its own counts.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTally

Returns a new instance of Tally.



20
21
22
23
24
25
26
# File 'lib/greenroom/recorder.rb', line 20

def initialize
  @comparisons = 0
  @mismatches = 0
  @ignored = 0
  @candidate_errors = 0
  @control_errors = 0
end

Instance Attribute Details

#candidate_errorsObject

Returns the value of attribute candidate_errors.



18
19
20
# File 'lib/greenroom/recorder.rb', line 18

def candidate_errors
  @candidate_errors
end

#comparisonsObject

Returns the value of attribute comparisons.



18
19
20
# File 'lib/greenroom/recorder.rb', line 18

def comparisons
  @comparisons
end

#control_errorsObject

Returns the value of attribute control_errors.



18
19
20
# File 'lib/greenroom/recorder.rb', line 18

def control_errors
  @control_errors
end

#ignoredObject

Returns the value of attribute ignored.



18
19
20
# File 'lib/greenroom/recorder.rb', line 18

def ignored
  @ignored
end

#mismatchesObject

Returns the value of attribute mismatches.



18
19
20
# File 'lib/greenroom/recorder.rb', line 18

def mismatches
  @mismatches
end

Instance Method Details

#to_hObject

String keys, not symbols: a Tally's hash only ever leaves this class inside Recorder#snapshot, and that Hash must already be shaped like JSON, because it travels through Sidekiq.dump_json / load_json (which always returns string keys) on the way to and from a cursor.



32
33
34
35
36
37
38
39
40
# File 'lib/greenroom/recorder.rb', line 32

def to_h
  {
    "comparisons" => comparisons,
    "mismatches" => mismatches,
    "ignored" => ignored,
    "candidate_errors" => candidate_errors,
    "control_errors" => control_errors
  }
end