mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-04-20 09:40:50 +01:00
telemetry: copy generated trace files into WA output
If trace files have been generated during a telemetry run (e.g. --profiler=trace was enabled), copy them into wa_output and extract them.
This commit is contained in:
parent
101d6a37ce
commit
698240b6e0
@ -3,6 +3,8 @@ import os
|
|||||||
import re
|
import re
|
||||||
import csv
|
import csv
|
||||||
import math
|
import math
|
||||||
|
import shutil
|
||||||
|
from zipfile import is_zipfile, ZipFile
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from wlauto import Workload, Parameter
|
from wlauto import Workload, Parameter
|
||||||
@ -14,6 +16,7 @@ from wlauto.utils.types import numeric, identifier
|
|||||||
RESULT_REGEX = re.compile(r'RESULT ([^:]+): ([^=]+)\s*=\s*' # preamble and test/metric name
|
RESULT_REGEX = re.compile(r'RESULT ([^:]+): ([^=]+)\s*=\s*' # preamble and test/metric name
|
||||||
r'(\[([^\]]+)\]|(\S+))' # value
|
r'(\[([^\]]+)\]|(\S+))' # value
|
||||||
r'\s*(\S+)') # units
|
r'\s*(\S+)') # units
|
||||||
|
TRACE_REGEX = re.compile(r'Trace saved as ([^\n]+)')
|
||||||
|
|
||||||
|
|
||||||
class Telemetry(Workload):
|
class Telemetry(Workload):
|
||||||
@ -119,7 +122,7 @@ class Telemetry(Workload):
|
|||||||
self.logger.debug(self.command)
|
self.logger.debug(self.command)
|
||||||
self.raw_output, _ = check_output(self.command, shell=True, timeout=self.run_timeout, ignore=1)
|
self.raw_output, _ = check_output(self.command, shell=True, timeout=self.run_timeout, ignore=1)
|
||||||
|
|
||||||
def update_result(self, context):
|
def update_result(self, context): # pylint: disable=too-many-locals
|
||||||
if not self.raw_output:
|
if not self.raw_output:
|
||||||
self.logger.warning('Did not get run_benchmark output.')
|
self.logger.warning('Did not get run_benchmark output.')
|
||||||
return
|
return
|
||||||
@ -128,7 +131,7 @@ class Telemetry(Workload):
|
|||||||
wfh.write(self.raw_output)
|
wfh.write(self.raw_output)
|
||||||
context.add_artifact('telemetry-raw', raw_outfile, kind='raw')
|
context.add_artifact('telemetry-raw', raw_outfile, kind='raw')
|
||||||
|
|
||||||
results = parse_telemetry_results(raw_outfile)
|
results, artifacts = parse_telemetry_results(raw_outfile)
|
||||||
csv_outfile = os.path.join(context.output_directory, 'telemetry.csv')
|
csv_outfile = os.path.join(context.output_directory, 'telemetry.csv')
|
||||||
averages = defaultdict(list)
|
averages = defaultdict(list)
|
||||||
with open(csv_outfile, 'wb') as wfh:
|
with open(csv_outfile, 'wb') as wfh:
|
||||||
@ -147,6 +150,17 @@ class Telemetry(Workload):
|
|||||||
for kind, values in averages.iteritems():
|
for kind, values in averages.iteritems():
|
||||||
context.result.add_metric(kind, special_average(values), lower_is_better=True)
|
context.result.add_metric(kind, special_average(values), lower_is_better=True)
|
||||||
|
|
||||||
|
for idx, artifact in enumerate(artifacts):
|
||||||
|
wa_path = os.path.join(context.output_directory,
|
||||||
|
os.path.basename(artifact))
|
||||||
|
shutil.copy(artifact, wa_path)
|
||||||
|
context.add_artifact('telemetry_trace_{}'.format(idx), path=wa_path, kind='data')
|
||||||
|
|
||||||
|
if is_zipfile(wa_path):
|
||||||
|
zf = ZipFile(wa_path)
|
||||||
|
zf.extractall(context.output_directory)
|
||||||
|
zf.close()
|
||||||
|
|
||||||
def teardown(self, context):
|
def teardown(self, context):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -190,6 +204,7 @@ class TelemetryResult(object):
|
|||||||
|
|
||||||
def parse_telemetry_results(filepath):
|
def parse_telemetry_results(filepath):
|
||||||
results = []
|
results = []
|
||||||
|
artifacts = []
|
||||||
with open(filepath) as fh:
|
with open(filepath) as fh:
|
||||||
for line in fh:
|
for line in fh:
|
||||||
match = RESULT_REGEX.search(line)
|
match = RESULT_REGEX.search(line)
|
||||||
@ -203,7 +218,10 @@ def parse_telemetry_results(filepath):
|
|||||||
result.values = [numeric(match.group(5))]
|
result.values = [numeric(match.group(5))]
|
||||||
result.units = match.group(6)
|
result.units = match.group(6)
|
||||||
results.append(result)
|
results.append(result)
|
||||||
return results
|
match = TRACE_REGEX.search(line)
|
||||||
|
if match:
|
||||||
|
artifacts.append(match.group(1))
|
||||||
|
return results, artifacts
|
||||||
|
|
||||||
|
|
||||||
def special_average(values):
|
def special_average(values):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user