Module: BatchExperiment::FirstLineExtractor

Extended by:
Extractor
Defined in:
lib/batch_experiment/sample_extractors.rb

Overview

A very simple sample extractor that extracts the first line of the command output, the run time and the memory usage (the last two are automatically added to any command output by ::batch and ::experiment).

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.



15
16
17
18
19
20
# File 'lib/batch_experiment/sample_extractors.rb', line 15

def self.extract_from_lines(lines)
  [ (lines[0] or ''),
    Extractor.get_field(lines, 'ext_time'),
    Extractor.get_field(lines, 'ext_mem')
  ]
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.



10
11
12
# File 'lib/batch_experiment/sample_extractors.rb', line 10

def self.names
  ['first_line', 'ext_time', 'ext_mem']
end