Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: mojo/tools/perf_test_runner.py

Issue 1421823002: Move performance dashboard upload logic to devtoolslib. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Move the argparse part too. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/tools/mopy/perf_data_uploader.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """A tool that runs a perf test and uploads the resulting data to the 6 """A tool that runs a perf test and uploads the resulting data to the
7 performance dashboard. 7 performance dashboard.
8
9 By default uploads to a local testing dashboard assumed to be running on the
10 host. To run such server, check out Catapult and follow instructions at
11 https://github.com/catapult-project/catapult/blob/master/dashboard/README.md .
8 """ 12 """
9 13
14 # TODO(yzshen): The following are missing currently:
15 # (1) CL range on the dashboard;
16 # (2) improvement direction on the dashboard;
17 # (3) a link from the build step pointing to the dashboard page.
18
10 import argparse 19 import argparse
11 import subprocess 20 import subprocess
12 import sys 21 import sys
13 import re 22 import re
14 23
15 from mopy import perf_data_uploader
16 from mopy.version import Version 24 from mopy.version import Version
17 25
26 import devtools
27 devtools.add_lib_to_path()
28 from devtoolslib import perf_dashboard
29
18 _PERF_LINE_FORMAT = r"""^\s*([^\s/]+) # chart name 30 _PERF_LINE_FORMAT = r"""^\s*([^\s/]+) # chart name
19 (/([^\s/]+))? # trace name (optional, separated with 31 (/([^\s/]+))? # trace name (optional, separated with
20 # the chart name by a '/') 32 # the chart name by a '/')
21 \s+(\S+) # value 33 \s+(\S+) # value
22 \s+(\S+) # units 34 \s+(\S+) # units
23 \s*$""" 35 \s*$"""
24 36
25 _PERF_LINE_REGEX = re.compile(_PERF_LINE_FORMAT, re.VERBOSE) 37 _PERF_LINE_REGEX = re.compile(_PERF_LINE_FORMAT, re.VERBOSE)
26 38
27 39
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 "benchmark_name": test_name, 72 "benchmark_name": test_name,
61 "charts": charts 73 "charts": charts
62 } 74 }
63 75
64 76
65 def main(): 77 def main():
66 parser = argparse.ArgumentParser( 78 parser = argparse.ArgumentParser(
67 description="A tool that runs a perf test and uploads the resulting data " 79 description="A tool that runs a perf test and uploads the resulting data "
68 "to the performance dashboard.") 80 "to the performance dashboard.")
69 81
70 parser.add_argument( 82 perf_dashboard.add_argparse_server_arguments(parser)
71 "--master-name",
72 help="Buildbot master name, used to construct link to buildbot log by "
73 "the dashboard, and also as the top-level category for the data.")
74 parser.add_argument(
75 "--perf-id",
76 help="Used as the second-level category for the data, usually the "
77 "platform type.")
78 parser.add_argument(
79 "--test-name",
80 help="Name of the test that the perf data was generated from.")
81 parser.add_argument(
82 "--builder-name",
83 help="Buildbot builder name, used to construct link to buildbot log by "
84 "the dashboard.")
85 parser.add_argument(
86 "--build-number", type=int,
87 help="Build number, used to construct link to buildbot log by the "
88 "dashboard.")
89 parser.add_argument( 83 parser.add_argument(
90 "--perf-data-path", 84 "--perf-data-path",
91 help="The path to the perf data that the perf test generates.") 85 help="The path to the perf data that the perf test generates.")
92 parser.add_argument(
93 "--dry-run", action="store_true", default=False,
94 help="Display the server URL and the data to upload, but do not actually "
95 "upload the data.")
96 server_group = parser.add_mutually_exclusive_group()
97 server_group.add_argument(
98 "--testing-dashboard", action="store_true", default=True,
99 help="Upload the data to the testing dashboard (default).")
100 server_group.add_argument(
101 "--production-dashboard", dest="testing_dashboard", action="store_false",
102 default=False, help="Upload the data to the production dashboard.")
103 parser.add_argument("command", nargs=argparse.REMAINDER) 86 parser.add_argument("command", nargs=argparse.REMAINDER)
104 args = parser.parse_args() 87 args = parser.parse_args()
105 88
106 subprocess.check_call(args.command) 89 subprocess.check_call(args.command)
107 90
108 if args.master_name is None or \ 91 if args.master_name is None or \
109 args.perf_id is None or \ 92 args.perf_id is None or \
110 args.test_name is None or \ 93 args.test_name is None or \
111 args.builder_name is None or \ 94 args.builder_name is None or \
112 args.build_number is None or \ 95 args.build_number is None or \
113 args.perf_data_path is None: 96 args.perf_data_path is None:
114 print "Won't upload perf data to the dashboard because not all of the " \ 97 print "Won't upload perf data to the dashboard because not all of the " \
115 "following values are specified: master-name, perf-id, test-name, " \ 98 "following values are specified: master-name, perf-id, test-name, " \
116 "builder-name, build-number, perf-data-path." 99 "builder-name, build-number, perf-data-path."
117 return 0 100 return 0
118 101
119 revision = Version().version 102 revision = Version().version
120 point_id = _GetCurrentCommitCount() 103 point_id = _GetCurrentCommitCount()
121 with open(args.perf_data_path, "r") as perf_data: 104 with open(args.perf_data_path, "r") as perf_data:
122 chart_data = _ConvertPerfDataToChartFormat(perf_data, args.test_name) 105 chart_data = _ConvertPerfDataToChartFormat(perf_data, args.test_name)
123 106
124 result = perf_data_uploader.UploadPerfData( 107 result = perf_dashboard.upload_chart_data(
125 args.master_name, args.perf_id, args.test_name, args.builder_name, 108 args.master_name, args.perf_id, args.test_name, args.builder_name,
126 args.build_number, revision, chart_data, point_id, args.dry_run, 109 args.build_number, revision, chart_data, point_id, args.server_url,
127 args.testing_dashboard) 110 args.dry_run)
128 111
129 return 0 if result else 1 112 return 0 if result else 1
130 113
131 114
132 if __name__ == '__main__': 115 if __name__ == '__main__':
133 sys.exit(main()) 116 sys.exit(main())
OLDNEW
« no previous file with comments | « mojo/tools/mopy/perf_data_uploader.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698