blob: b40d3c78553eea3b0b0fd4c4020b4518216cb60b [file] [log] [blame]
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Routines for reading performance results from a directory.
The directory should match the format created by the 'bootperf'
script; see comments in that script for a summary of the layout.
import fnmatch
import os
import re
import resultset
_PERF_KEYVAL_PATTERN = re.compile("(.*){perf}=(.*)\n")
def _ReadKeyvalFile(results, file_):
"""Read an autotest keyval file, and process the results.
The `file_` parameter is a file object with contents in autotest
perf keyval format:
Each iteration of the test is terminated with a single blank line,
including the last iteration. Each iteration's results are added
to the `results` parameter, which should be an instance of
@param results A TestResultSet where the result data will be
@param file_ File object for the results file to be read.
kvd = {}
for line in iter(file_):
if line == "\n":
kvd = {}
m = _PERF_KEYVAL_PATTERN.match(line)
if m is None:
kvd[] =
_RESULTS_PATH = "summary/platform_BootPerfServer/results/keyval"
def ReadResultsDirectory(dir_):
"""Process results from a 'bootperf' output directory.
The accumulated results are returned in a newly created
TestResultSet object.
@param dir_ The directory containing the test results keyval file.
res_set = resultset.TestResultSet(dir_)
dirlist = fnmatch.filter(os.listdir(dir_), "run.???")
for rundir in dirlist:
keyval_path = os.path.join(dir_, rundir, _RESULTS_PATH)
kvf = open(keyval_path)
except IOError:
_ReadKeyvalFile(res_set, kvf)
return res_set