OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Runs perf tests. | 5 """Runs perf tests. |
6 | 6 |
7 Our buildbot infrastructure requires each slave to run steps serially. | 7 Our buildbot infrastructure requires each slave to run steps serially. |
8 This is sub-optimal for android, where these steps can run independently on | 8 This is sub-optimal for android, where these steps can run independently on |
9 multiple connected devices. | 9 multiple connected devices. |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 def OutputJsonList(json_input, json_output): | 69 def OutputJsonList(json_input, json_output): |
70 with file(json_input, 'r') as i: | 70 with file(json_input, 'r') as i: |
71 all_steps = json.load(i) | 71 all_steps = json.load(i) |
72 step_names = all_steps['steps'].keys() | 72 step_names = all_steps['steps'].keys() |
73 with file(json_output, 'w') as o: | 73 with file(json_output, 'w') as o: |
74 o.write(json.dumps(step_names)) | 74 o.write(json.dumps(step_names)) |
75 return 0 | 75 return 0 |
76 | 76 |
77 | 77 |
78 def OutputChartjson(test_name, json_file_name): | 78 def PrintTestOutput(test_name, json_file_name=None): |
79 file_name = os.path.join(constants.PERF_OUTPUT_DIR, test_name) | |
80 with file(file_name, 'r') as f: | |
81 persisted_result = pickle.load(f) | |
82 with open(json_file_name, 'w') as o: | |
83 o.write(persisted_result['chartjson']) | |
84 | |
85 | |
86 def PrintTestOutput(test_name): | |
87 """Helper method to print the output of previously executed test_name. | 79 """Helper method to print the output of previously executed test_name. |
88 | 80 |
89 Args: | 81 Args: |
90 test_name: name of the test that has been previously executed. | 82 test_name: name of the test that has been previously executed. |
| 83 json_file_name: name of the file to output chartjson data to. |
91 | 84 |
92 Returns: | 85 Returns: |
93 exit code generated by the test step. | 86 exit code generated by the test step. |
94 """ | 87 """ |
95 file_name = os.path.join(constants.PERF_OUTPUT_DIR, test_name) | 88 file_name = os.path.join(constants.PERF_OUTPUT_DIR, test_name) |
96 if not os.path.exists(file_name): | 89 if not os.path.exists(file_name): |
97 logging.error('File not found %s', file_name) | 90 logging.error('File not found %s', file_name) |
98 return 1 | 91 return 1 |
99 | 92 |
100 with file(file_name, 'r') as f: | 93 with file(file_name, 'r') as f: |
101 persisted_result = pickle.loads(f.read()) | 94 persisted_result = pickle.loads(f.read()) |
102 logging.info('*' * 80) | 95 logging.info('*' * 80) |
103 logging.info('Output from:') | 96 logging.info('Output from:') |
104 logging.info(persisted_result['cmd']) | 97 logging.info(persisted_result['cmd']) |
105 logging.info('*' * 80) | 98 logging.info('*' * 80) |
106 print persisted_result['output'] | 99 print persisted_result['output'] |
107 | 100 |
| 101 if json_file_name: |
| 102 with file(json_file_name, 'w') as f: |
| 103 f.write(persisted_result['chartjson']) |
| 104 |
108 return persisted_result['exit_code'] | 105 return persisted_result['exit_code'] |
109 | 106 |
110 | 107 |
111 def PrintSummary(test_names): | 108 def PrintSummary(test_names): |
112 logging.info('*' * 80) | 109 logging.info('*' * 80) |
113 logging.info('Sharding summary') | 110 logging.info('Sharding summary') |
114 device_total_time = collections.defaultdict(int) | 111 device_total_time = collections.defaultdict(int) |
115 for test_name in test_names: | 112 for test_name in test_names: |
116 file_name = os.path.join(constants.PERF_OUTPUT_DIR, test_name) | 113 file_name = os.path.join(constants.PERF_OUTPUT_DIR, test_name) |
117 if not os.path.exists(file_name): | 114 if not os.path.exists(file_name): |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 Returns: | 327 Returns: |
331 A tuple of (TestRunResults, retry). | 328 A tuple of (TestRunResults, retry). |
332 """ | 329 """ |
333 _, result_type = self._LaunchPerfTest(test_name) | 330 _, result_type = self._LaunchPerfTest(test_name) |
334 results = base_test_result.TestRunResults() | 331 results = base_test_result.TestRunResults() |
335 results.AddResult(base_test_result.BaseTestResult(test_name, result_type)) | 332 results.AddResult(base_test_result.BaseTestResult(test_name, result_type)) |
336 retry = None | 333 retry = None |
337 if not results.DidRunPass(): | 334 if not results.DidRunPass(): |
338 retry = test_name | 335 retry = test_name |
339 return results, retry | 336 return results, retry |
OLD | NEW |