Commit 1c4ae62d authored by Camillo Bruni's avatar Camillo Bruni Committed by V8 LUCI CQ

[tools] Make run_perf.py python3 compatible

map, filter and values do not return lists in python3.

Change-Id: I608e8f61649f60f6cfeb9c4e12d293655c5647de
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3107305Reviewed-by: 's avatarLutz Vahl <vahl@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76450}
parent 7b6b1b1d
......@@ -126,6 +126,7 @@ from testrunner.local import command
from testrunner.local import utils
from testrunner.objects.output import Output, NULL_OUTPUT
# for py2/py3 compatibility
try:
basestring # Python 2
except NameError: # Python 3
......@@ -152,7 +153,7 @@ def GeometricMean(values):
The mean is calculated using log to avoid overflow.
"""
values = map(float, values)
values = list(map(float, values))
return math.exp(sum(map(math.log, values)) / len(values))
......@@ -224,9 +225,9 @@ class ResultTracker(object):
def ToDict(self):
return {
'traces': self.traces.values(),
'traces': list(self.traces.values()),
'errors': self.errors,
'runnables': self.runnables.values(),
'runnables': list(self.runnables.values()),
}
def WriteToFile(self, file_name):
......@@ -596,9 +597,11 @@ def find_build_directory(base_path, arch):
'Release',
]
possible_paths = [os.path.join(base_path, p) for p in possible_paths]
actual_paths = filter(is_build, possible_paths)
actual_paths = list(filter(is_build, possible_paths))
assert actual_paths, 'No build directory found.'
assert len(actual_paths) == 1, 'Found ambiguous build directories.'
assert len(
actual_paths
) == 1, 'Found ambiguous build directories use --binary-override-path.'
return actual_paths[0]
......@@ -677,10 +680,10 @@ class DesktopPlatform(Platform):
if args.prioritize:
self.command_prefix += ['-n', '-20']
if args.affinitize != None:
# schedtool expects a bit pattern when setting affinity, where each
# bit set to '1' corresponds to a core where the process may run on.
# First bit corresponds to CPU 0. Since the 'affinitize' parameter is
# a core number, we need to map to said bit pattern.
# schedtool expects a bit pattern when setting affinity, where each
# bit set to '1' corresponds to a core where the process may run on.
# First bit corresponds to CPU 0. Since the 'affinitize' parameter is
# a core number, we need to map to said bit pattern.
cpu = int(args.affinitize)
core = 1 << cpu
self.command_prefix += ['-a', ('0x%x' % core)]
......@@ -841,10 +844,10 @@ class CustomMachineConfiguration:
try:
with open('/sys/devices/system/cpu/present', 'r') as f:
indexes = f.readline()
r = map(int, indexes.split('-'))
r = list(map(int, indexes.split('-')))
if len(r) == 1:
return range(r[0], r[0] + 1)
return range(r[0], r[1] + 1)
return list(range(r[0], r[0] + 1))
return list(range(r[0], r[1] + 1))
except Exception:
logging.exception('Failed to retrieve number of CPUs.')
raise
......@@ -1034,7 +1037,7 @@ def Main(argv):
# Ensure all arguments have absolute path before we start changing current
# directory.
args.suite = map(os.path.abspath, args.suite)
args.suite = list(map(os.path.abspath, args.suite))
prev_aslr = None
prev_cpu_gov = None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment