def extract_metric(metric, line, result, prefix='', lower_is_better=True):
    try:
        name, value_part = [part.strip() for part in line.split(':')]
        if name != metric:
            message = 'Name mismatch: expected "{}", got "{}"'
            raise WorkloadError(message.format(metric, name.strip()))
        if not value_part or not value_part[0].isdigit():
            raise ValueError(
                'value part does not start with a digit: {}'.format(
                    value_part))
        idx = -1
        if not value_part[idx].isdigit(
        ):  # units detected at the end of the line
            while not value_part[idx - 1].isdigit():
                idx -= 1
            value = numeric(value_part[:idx])
            units = value_part[idx:]
        else:
            value = numeric(value_part)
            units = None
        result.add_metric(prefix + metric,
                          value,
                          units,
                          lower_is_better=lower_is_better)
    except Exception as e:
        message = 'Could not extract sysbench metric "{}"; got "{}"'
        raise WorkloadError(message.format(prefix + metric, e))
    def __init__(self, thread, cpu_id, ts, name, body, parser=None):
        """
        parameters:

        :thread: thread which generated the event
        :cpu: cpu on which the event has occurred
        :ts: timestamp of the event
        :name: the name of the event
        :bodytext: a string with the rest of the event text
        :parser: optionally, a function that will parse bodytext to populate
                 this event's attributes

        The parser can be any callable that can be invoked with

            parser(event, text)

        Where ``event`` is this TraceCmdEvent instance, and ``text`` is the body text to be
        parsed. The parser should updated the passed event instance and not return anything
        (the return value will be ignored). Any exceptions raised by the parser will be silently
        ignored (note that this means that the event's attributes may be partially initialized).

        """
        self.thread = thread
        self.reporting_cpu_id = int(cpu_id)
        self.timestamp = numeric(ts)
        self.name = name
        self.text = body
        self._fields = None
        self._parser = parser
Example #3
0
 def update_result(self, context):
     if not self.raw_output:
         self.logger.warning(
             'No power_LoadTest output detected; run failed?')
         return
     raw_outfile = os.path.join(context.output_directory,
                                'autotest-output.raw')
     with open(raw_outfile, 'w') as wfh:
         wfh.write(self.raw_output)
     context.add_artifact('autotest_raw', raw_outfile, kind='raw')
     lines = iter(self.raw_output.split('\n'))
     # Results are delimitted from the rest of the output by MARKER
     for line in lines:
         if MARKER in line:
             break
     for line in lines:
         match = STATUS_REGEX.search(line)
         if match:
             status = match.group(1)
             if status != 'PASSED':
                 self.logger.warning(line)
         match = METRIC_REGEX.search(line)
         if match:
             try:
                 context.result.add_metric(match.group(1),
                                           numeric(match.group(2)),
                                           lower_is_better=True)
             except ValueError:
                 pass  # non-numeric metrics aren't supported
    def __init__(self, thread, cpu_id, ts, name, body, parser=None):
        """
        parameters:

        :thread: thread which generated the event
        :cpu: cpu on which the event has occurred
        :ts: timestamp of the event
        :name: the name of the event
        :bodytext: a string with the rest of the event text
        :parser: optionally, a function that will parse bodytext to populate
                 this event's attributes

        The parser can be any callable that can be invoked with

            parser(event, text)

        Where ``event`` is this TraceCmdEvent instance, and ``text`` is the body text to be
        parsed. The parser should updated the passed event instance and not return anything
        (the return value will be ignored). Any exceptions raised by the parser will be silently
        ignored (note that this means that the event's attributes may be partially initialized).

        """
        self.thread = thread
        self.reporting_cpu_id = int(cpu_id)
        self.timestamp = numeric(ts)
        self.name = name
        self.text = body
        self._fields = None
        self._parser = parser
Example #5
0
 def update_result(self, context):
     if not self.raw_output:
         self.logger.warning('No power_LoadTest output detected; run failed?')
         return
     raw_outfile = os.path.join(context.output_directory, 'autotest-output.raw')
     with open(raw_outfile, 'w') as wfh:
         wfh.write(self.raw_output)
     context.add_artifact('autotest_raw', raw_outfile, kind='raw')
     lines = iter(self.raw_output.split('\n'))
     # Results are delimitted from the rest of the output by MARKER
     for line in lines:
         if MARKER in line:
             break
     for line in lines:
         match = STATUS_REGEX.search(line)
         if match:
             status = match.group(1)
             if status != 'PASSED':
                 self.logger.warning(line)
         match = METRIC_REGEX.search(line)
         if match:
             try:
                 context.result.add_metric(match.group(1), numeric(match.group(2)), lower_is_better=True)
             except ValueError:
                 pass  # non-numeric metrics aren't supported
Example #6
0
def try_convert_to_numeric(v):
    try:
        if isiterable(v):
            return map(numeric, v)
        else:
            return numeric(v)
    except ValueError:
        return v
def try_convert_to_numeric(v):
    try:
        if isiterable(v):
            return map(numeric, v)
        else:
            return numeric(v)
    except ValueError:
        return v
Example #8
0
 def __init__(self,
              name,
              value,
              units=None,
              lower_is_better=False,
              classifiers=None):
     self.name = name
     self.value = numeric(value)
     self.units = units
     self.lower_is_better = lower_is_better
     self.classifiers = classifiers or {}
Example #9
0
def extract_metric(metric, line, result, prefix='', lower_is_better=True):
    try:
        name, value_part = [part.strip() for part in line.split(':')]
        if name != metric:
            message = 'Name mismatch: expected "{}", got "{}"'
            raise WorkloadError(message.format(metric, name.strip()))
        if not value_part or not value_part[0].isdigit():
            raise ValueError('value part does not start with a digit: {}'.format(value_part))
        idx = -1
        if not value_part[idx].isdigit():  # units detected at the end of the line
            while not value_part[idx - 1].isdigit():
                idx -= 1
            value = numeric(value_part[:idx])
            units = value_part[idx:]
        else:
            value = numeric(value_part)
            units = None
        result.add_metric(prefix + metric,
                          value, units, lower_is_better=lower_is_better)
    except Exception as e:
        message = 'Could not extract sysbench metric "{}"; got "{}"'
        raise WorkloadError(message.format(prefix + metric, e))
Example #10
0
def extract_threads_fairness_metric(metric, line, result):
    try:
        name_part, value_part = [part.strip() for part in line.split(':')]
        name = name_part.split('(')[0].strip()
        if name != metric:
            message = 'Name mismatch: expected "{}", got "{}"'
            raise WorkloadError(message.format(metric, name))
        avg, stddev = [numeric(v) for v in value_part.split('/')]
        result.add_metric('thread fairness {} avg'.format(metric), avg)
        result.add_metric('thread fairness {} stddev'.format(metric),
                          stddev, lower_is_better=True)
    except Exception as e:
        message = 'Could not extract sysbench metric "{}"; got "{}"'
        raise WorkloadError(message.format(metric, e))
Example #11
0
def extract_threads_fairness_metric(metric, line, result):
    try:
        name_part, value_part = [part.strip() for part in line.split(':')]
        name = name_part.split('(')[0].strip()
        if name != metric:
            message = 'Name mismatch: expected "{}", got "{}"'
            raise WorkloadError(message.format(metric, name))
        avg, stddev = [numeric(v) for v in value_part.split('/')]
        result.add_metric('thread fairness {} avg'.format(metric), avg)
        result.add_metric('thread fairness {} stddev'.format(metric),
                          stddev,
                          lower_is_better=True)
    except Exception as e:
        message = 'Could not extract sysbench metric "{}"; got "{}"'
        raise WorkloadError(message.format(metric, e))
Example #12
0
def extract_metric(metric, line, result, prefix='', lower_is_better=True):
    try:
        name, value_part = [part.strip() for part in line.split(':')]
        if name != metric:
            message = 'Name mismatch: expected "{}", got "{}"'
            raise WorkloadError(message.format(metric, name.strip()))
        idx = -1
        while value_part[idx - 1].isalpha() and idx:  # assumes at least one char of units
            idx -= 1
        if not idx:
            raise WorkloadError('Could not parse value "{}"'.format(value_part))
        value = numeric(value_part[:idx])
        units = value_part[idx:]
        result.add_metric(prefix + metric,
                          value, units, lower_is_better=lower_is_better)
    except Exception as e:
        message = 'Could not extract sysbench metric "{}"; got "{}"'
        raise WorkloadError(message.format(prefix + metric, e))
Example #13
0
def parse_telemetry_results(filepath):
    results = []
    artifacts = []
    with open(filepath) as fh:
        for line in fh:
            match = RESULT_REGEX.search(line)
            if match:
                result = TelemetryResult()
                result.kind = match.group(1)
                result.url = match.group(2)
                if match.group(4):
                    result.values = map(numeric, match.group(4).split(','))
                else:
                    result.values = [numeric(match.group(5))]
                result.units = match.group(6)
                results.append(result)
            match = TRACE_REGEX.search(line)
            if match:
                artifacts.append(match.group(1))
    return results, artifacts
Example #14
0
 def __init__(self, name, value, units=None, lower_is_better=False, classifiers=None):
     self.name = name
     self.value = numeric(value)
     self.units = units
     self.lower_is_better = lower_is_better
     self.classifiers = classifiers or {}