Commit 050128c6 authored by Ned Nguyen's avatar Ned Nguyen Committed by Commit Bot

Simplify & improve the effciency of SQL query of test timing data

This CL also rerun the query for 'android-go-perf' with:

./tools/perf/core/retrieve_story_timing.py -c 'android-go-perf'  --output-file=tools/perf/core/shard_maps/timing_data/android_go_timing.json

Bug: 863768
Cq-Include-Trybots: master.tryserver.chromium.perf:obbs_fyi
Change-Id: Icfc132854aa83d35a9e27cbd5dfc42aeae5b3361
Reviewed-on: https://chromium-review.googlesource.com/1158966Reviewed-by: default avatarJohn Budorick <jbudorick@chromium.org>
Commit-Queue: Ned Nguyen <nednguyen@google.com>
Cr-Commit-Position: refs/heads/master@{#580156}
parent 6de946db
...@@ -28,33 +28,25 @@ ORDER BY ...@@ -28,33 +28,25 @@ ORDER BY
QUERY_LAST_RUNS = """ QUERY_LAST_RUNS = """
SELECT SELECT
name, name,
ROUND(AVG(time)) AS duration ROUND(AVG(time)) AS duration,
FROM ( FROM (
SELECT SELECT
name, run.name AS name,
start_time, start_time,
time, AVG(run.times) AS time
ROW_NUMBER() OVER (PARTITION BY name ORDER BY start_time DESC) FROM
AS row_num [test-results-hrd:events.test_results]
FROM ( WHERE
SELECT buildbot_info.builder_name IN ({configuration_names})
run.name AS name, AND run.time IS NOT NULL
start_time, AND run.time != 0
AVG(run.times) AS time AND run.is_unexpected IS FALSE
FROM AND DATEDIFF(CURRENT_DATE(), DATE(start_time)) < {num_last_days}
[test-results-hrd:events.test_results] GROUP BY
WHERE name,
buildbot_info.builder_name IN ({configuration_names}) start_time
AND run.time IS NOT NULL ORDER BY
AND run.time != 0 start_time DESC)
AND run.is_unexpected IS FALSE
GROUP BY
name,
start_time
ORDER BY
start_time DESC ))
WHERE
row_num < {num_last_builds}
GROUP BY GROUP BY
name name
ORDER BY ORDER BY
...@@ -64,14 +56,15 @@ ORDER BY ...@@ -64,14 +56,15 @@ ORDER BY
def _run_query(query): def _run_query(query):
args = ["bq", "query", "--format=json", "--max_rows=100000", query] args = ["bq", "query", "--format=json", "--max_rows=100000", query]
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if p.wait() == 0: stdout, stderr = p.communicate()
json_result = p.stdout.read().strip() if p.returncode == 0:
return json.loads(json_result) return json.loads(stdout)
else: else:
raise RuntimeError( raise RuntimeError(
'Error generating authentication token.\nStdout: %s\nStder:%s' % 'Error generating authentication token.\nStdout: %s\nStder:%s' %
(p.stdout.read(), p.stderr.read())) (stdout, stderr))
def FetchStoryTimingDataForSingleBuild(configurations, build_number): def FetchStoryTimingDataForSingleBuild(configurations, build_number):
...@@ -79,9 +72,9 @@ def FetchStoryTimingDataForSingleBuild(configurations, build_number): ...@@ -79,9 +72,9 @@ def FetchStoryTimingDataForSingleBuild(configurations, build_number):
configurations, build_number)) configurations, build_number))
def FetchAverageStortyTimingData(configurations, num_last_builds): def FetchAverageStortyTimingData(configurations, num_last_days):
return _run_query(QUERY_LAST_RUNS.format( return _run_query(QUERY_LAST_RUNS.format(
configuration_names=configurations, num_last_builds=num_last_builds)) configuration_names=configurations, num_last_days=num_last_days))
def main(args): def main(args):
...@@ -115,7 +108,7 @@ def main(args): ...@@ -115,7 +108,7 @@ def main(args):
data = FetchStoryTimingDataForSingleBuild(configurations, data = FetchStoryTimingDataForSingleBuild(configurations,
opts.build_number) opts.build_number)
else: else:
data = FetchAverageStortyTimingData(configurations, num_last_builds=10) data = FetchAverageStortyTimingData(configurations, num_last_days=5)
with open(opts.output_file, 'w') as output_file: with open(opts.output_file, 'w') as output_file:
json.dump(data, output_file, indent = 4, separators=(',', ': ')) json.dump(data, output_file, indent = 4, separators=(',', ': '))
......
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