Fix perf_test_runner.py to run with python3

perf_test_runner.py doesn't run properly after recent python migration.
Fix by decoding output (bytes) to string using utf-8 and then re.serach
the string.

Bug: None
Change-Id: Id988d0f5161d0c9edc827a48a3a30f8e60f8f814
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119080
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Shrek Shao <shrekshao@google.com>
This commit is contained in:
shrekshao 2023-02-08 00:48:37 +00:00 committed by Dawn LUCI CQ
parent 831ff0e39d
commit 9e03212925
1 changed files with 11 additions and 5 deletions

View File

@ -22,8 +22,12 @@ import sys
import os
import re
# Assume running the dawn_perf_tests build in Chromium checkout
# Dawn locates at /path/to/Chromium/src/third_party/dawn/
# Chromium build usually locates at /path/to/Chromium/src/out/Release/
# You might want to change the base_path if you want to run dawn_perf_tests build from a Dawn standalone build.
base_path = os.path.abspath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../'))
# Look for a [Rr]elease build.
perftests_paths = glob.glob('out/*elease*')
@ -112,17 +116,19 @@ def get_results(metric, extra_args=[]):
stderr=subprocess.PIPE)
output, err = process.communicate()
m = re.search(r'Running (\d+) tests', output)
output_string = output.decode('utf-8')
m = re.search(r"Running (\d+) tests", output_string)
if m and int(m.group(1)) > 1:
print("Found more than one test result in output:")
print(output)
print(output_string)
sys.exit(3)
pattern = metric + r'.*= ([0-9.]+)'
m = re.findall(pattern, output)
m = re.findall(pattern, output_string)
if not m:
print("Did not find the metric '%s' in the test output:" % metric)
print(output)
print(output_string)
sys.exit(1)
return [float(value) for value in m]