Class: BatchExperiment::PyaExtractor

Inherits:
Object
  • Object
show all
Extended by:
Extractor
Defined in:
lib/batch_experiment/sample_extractors.rb

Overview

Extractor for the output of the pyasukp program available at github.com/henriquebecker91/masters. Not of interest for the majority of the users of this gem. Kept as example, and for this gem author personal use.

Class Method Summary collapse

Methods included from Extractor

extract, extract_from_lines, get_field, get_hfield, names

Class Method Details

.extract_from_lines(lines) ⇒ Array<String>

Optionally, you can define this method instead of #extract. The #extract method will call this method if not overrided.

Parameters:

  • lines (Array<String>)

    Program output, broken in lines, and the line string elements don’t end in linebreak.

Returns:

  • (Array<String>)

    The N extracted values, as strings.



60
61
62
63
64
65
66
# File 'lib/batch_experiment/sample_extractors.rb', line 60

def self.extract_from_lines(lines)
  values = ['Total Time ', 'ext_time', 'ext_mem'].map do | label |
    Extractor.get_field(lines, label)
  end
  opt_key = '#The optimal value for the given capacity'
  values << Extractor.get_hfield(lines, opt_key)
end

.namesArray<String>

Note:

To be on the safe side you should create a new array at each call. If you always return a reference to the same array the array can be modified.

Return the field names for each of the elements returned by extract. Ex.:

['Time', 'Max Mem Use', 'opt', ... ]

Returns:

  • (Array<String>)

    The strings that will be used to make the column names at the BatchExperiment.experiment method.



55
56
57
# File 'lib/batch_experiment/sample_extractors.rb', line 55

def self.names
  ['internal_time', 'external_time', 'external_memory', 'opt']
end