| OLD | NEW |
| 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 """ | 8 """ |
| 9 | 9 |
| 10 import argparse | 10 import argparse |
| 11 from mopy import perf_data_uploader | 11 from mopy import perf_data_uploader |
| 12 from mopy.version import Version | 12 from mopy.version import Version |
| 13 import subprocess | 13 import subprocess |
| 14 import sys | 14 import sys |
| 15 | 15 |
| 16 | 16 |
| 17 def _GetCurrentCommitCount(): | |
| 18 return subprocess.check_output( | |
| 19 ["git", "rev-list", "HEAD", "--count"]).strip() | |
| 20 | |
| 21 | |
| 22 def main(): | 17 def main(): |
| 23 parser = argparse.ArgumentParser( | 18 parser = argparse.ArgumentParser( |
| 24 description="A tool that runs a perf test and uploads the resulting data " | 19 description="A tool that runs a perf test and uploads the resulting data " |
| 25 "to the performance dashboard.") | 20 "to the performance dashboard.") |
| 26 | 21 |
| 27 parser.add_argument( | 22 parser.add_argument( |
| 28 "--master-name", | 23 "--master-name", |
| 29 help="Buildbot master name, used to construct link to buildbot log by " | 24 help="Buildbot master name, used to construct link to buildbot log by " |
| 30 "the dashboard, and also as the top-level category for the data.") | 25 "the dashboard, and also as the top-level category for the data.") |
| 31 parser.add_argument( | 26 parser.add_argument( |
| 32 "--perf-id", | 27 "--perf-id", |
| 33 help="Used as the second-level category for the data, usually the " | 28 help="Used as the second-level category for the data, usually the " |
| 34 "platform type.") | 29 "platform type.") |
| 35 parser.add_argument( | 30 parser.add_argument( |
| 36 "--test-name", | 31 "--test-name", |
| 37 help="Name of the test that the perf data was generated from.") | 32 help="Name of the test that the perf data was generated from.") |
| 38 parser.add_argument( | 33 parser.add_argument( |
| 39 "--builder-name", | 34 "--builder-name", |
| 40 help="Buildbot builder name, used to construct link to buildbot log by " | 35 help="Buildbot builder name, used to construct link to buildbot log by " |
| 41 "the dashboard.") | 36 "the dashboard.") |
| 42 parser.add_argument( | 37 parser.add_argument( |
| 43 "--build-number", type=int, | 38 "--build-number", type=int, |
| 44 help="Build number, used to construct link to buildbot log by the " | 39 help="Build number, used to construct link to buildbot log by the " |
| 45 "dashboard.") | 40 "dashboard.") |
| 46 parser.add_argument( | 41 parser.add_argument( |
| 47 "--perf-data-path", | 42 "--perf-data-path", |
| 48 help="The path to the perf data that the perf test generates.") | 43 help="The path to the perf data that the perf test generates.") |
| 44 parser.add_argument( |
| 45 "--point-id", type=int, |
| 46 help="The x coordinate for the data points.") |
| 49 server_group = parser.add_mutually_exclusive_group() | 47 server_group = parser.add_mutually_exclusive_group() |
| 50 server_group.add_argument( | 48 server_group.add_argument( |
| 51 "--testing-dashboard", action="store_true", default=True, | 49 "--testing-dashboard", action="store_true", default=True, |
| 52 help="Upload the data to the testing dashboard (default).") | 50 help="Upload the data to the testing dashboard (default).") |
| 53 server_group.add_argument( | 51 server_group.add_argument( |
| 54 "--production-dashboard", dest="testing_dashboard", action="store_false", | 52 "--production-dashboard", dest="testing_dashboard", action="store_false", |
| 55 default=False, help="Upload the data to the production dashboard.") | 53 default=False, help="Upload the data to the production dashboard.") |
| 56 parser.add_argument("command", nargs=argparse.REMAINDER) | 54 parser.add_argument("command", nargs=argparse.REMAINDER) |
| 57 args = parser.parse_args() | 55 args = parser.parse_args() |
| 58 | 56 |
| 59 subprocess.check_call(args.command) | 57 subprocess.check_call(args.command) |
| 60 | 58 |
| 61 if args.master_name is None or \ | 59 if args.master_name is None or \ |
| 62 args.perf_id is None or \ | 60 args.perf_id is None or \ |
| 63 args.test_name is None or \ | 61 args.test_name is None or \ |
| 64 args.builder_name is None or \ | 62 args.builder_name is None or \ |
| 65 args.build_number is None or \ | 63 args.build_number is None or \ |
| 66 args.perf_data_path is None: | 64 args.perf_data_path is None or \ |
| 65 args.point_id is None: |
| 67 print "Won't upload perf data to the dashboard because not all of the " \ | 66 print "Won't upload perf data to the dashboard because not all of the " \ |
| 68 "following values are specified: master-name, perf-id, test-name, " \ | 67 "following values are specified: master-name, perf-id, test-name, " \ |
| 69 "builder-name, build-number, perf-data-path." | 68 "builder-name, build-number, perf-data-path, point-id." |
| 70 return 0 | 69 return 0 |
| 71 | 70 |
| 72 revision = Version().version | 71 revision = Version().version |
| 73 perf_data = open(args.perf_data_path, "r") | 72 perf_data = open(args.perf_data_path, "r") |
| 74 point_id = _GetCurrentCommitCount() | |
| 75 | 73 |
| 76 result = perf_data_uploader.UploadPerfData( | 74 result = perf_data_uploader.UploadPerfData( |
| 77 args.master_name, args.perf_id, args.test_name, args.builder_name, | 75 args.master_name, args.perf_id, args.test_name, args.builder_name, |
| 78 args.build_number, revision, perf_data, point_id, False, | 76 args.build_number, revision, perf_data, args.point_id, False, |
| 79 args.testing_dashboard) | 77 args.testing_dashboard) |
| 80 | 78 |
| 81 return 0 if result else 1 | 79 return 0 if result else 1 |
| 82 | 80 |
| 83 | 81 |
| 84 if __name__ == '__main__': | 82 if __name__ == '__main__': |
| 85 sys.exit(main()) | 83 sys.exit(main()) |
| OLD | NEW |