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

Unified Diff: build/android/pylib/perf/perf_test_instance.py

Issue 2012323002: [Android] Implement perf tests to platform mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add retry logic and some clean up Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: build/android/pylib/perf/perf_test_instance.py
diff --git a/build/android/pylib/perf/perf_test_instance.py b/build/android/pylib/perf/perf_test_instance.py
new file mode 100644
index 0000000000000000000000000000000000000000..5d2f00f372063011a420a9ec730714ad9a4bd44e
--- /dev/null
+++ b/build/android/pylib/perf/perf_test_instance.py
@@ -0,0 +1,113 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
mikecase (-- gone --) 2016/06/01 17:40:28 nit 2016
rnephew (Reviews Here) 2016/06/01 20:32:05 Done.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import json
+import logging
+import os
+import pickle
+
+from pylib import constants
+from pylib.base import test_instance
+from pylib.constants import exit_codes
+
+
+def _GetPersistedResult(test_name):
+ file_name = os.path.join(constants.PERF_OUTPUT_DIR, test_name)
+ if not os.path.exists(file_name):
+ logging.error('File not found %s', file_name)
+ return None
+
+ with file(file_name, 'r') as f:
+ return pickle.loads(f.read())
+
+
+class PerfTestInstance(test_instance.TestInstance):
+ def __init__(self, args, _):
+ self._STR = 'Local Device Perf Test Instance: '
jbudorick 2016/06/01 17:44:11 Nothing in here should be specific to a local devi
rnephew (Reviews Here) 2016/06/01 20:32:05 This is just left over debuggign information anywa
+ super(PerfTestInstance, self).__init__()
+
+ if args.single_step:
+ args.single_step = ' '.join(args.single_step_command)
+ self.steps = args.steps
jbudorick 2016/06/01 17:44:11 1) Why is so much of this public? It really should
rnephew (Reviews Here) 2016/06/01 20:32:05 Woops. I meant to do a pass through this and make
+ self.flaky_steps = args.flaky_steps
+ self.output_json_list = args.output_json_list
+ self.print_step = args.print_step
+ self.single_step = args.single_step
+ self.no_timeout = args.no_timeout
+ self.test_filter = args.test_filter
+ self.dry_run = args.dry_run
+ self.collect_chartjson_data = args.collect_chartjson_data
+ self._output_chartjson_data = args.output_chartjson_data
+ self._get_output_dir_archive = args.get_output_dir_archive
+ self.max_battery_temp = args.max_battery_temp
+ self.min_battery_level = args.min_battery_level
+ self.known_devices_file = args.known_devices_file
+
+ def SetUp(self):
+ pass
+
+ def TearDown(self):
+ pass
+
+ def OutputJsonList(self):
+ with file(self.steps, 'r') as i:
+ all_steps = json.load(i)
+
+ step_values = []
+ for k, v in all_steps['steps'].iteritems():
+ data = {'test': k, 'device_affinity': v['device_affinity']}
+
+ persisted_result = _GetPersistedResult(k)
+ if persisted_result:
+ data['start_time'] = persisted_result['start_time']
+ data['end_time'] = persisted_result['end_time']
+ data['total_time'] = persisted_result['total_time']
+ data['has_archive'] = persisted_result['archive_bytes'] is not None
+ step_values.append(data)
+
+ with file(self.output_json_list, 'w') as o:
+ o.write(json.dumps(step_values))
+ return 0
+
jbudorick 2016/06/01 17:44:11 nit: only one line between member functions
rnephew (Reviews Here) 2016/06/01 20:32:05 Done.
+
+ def PrintTestOutput(self):
+ """Helper method to print the output of previously executed test_name.
+
+ Test_name is passed from the command line as print_step
+
+ Returns:
+ exit code generated by the test step.
+ """
+ persisted_result = _GetPersistedResult(self.print_step)
+ if not persisted_result:
+ return exit_codes.INFRA
+ logging.info('*' * 80)
+ logging.info('Output from:')
+ logging.info(persisted_result['cmd'])
+ logging.info('*' * 80)
+
+ output_formatted = ''
+ persisted_outputs = persisted_result['output']
+ for i in xrange(len(persisted_outputs)):
+ output_formatted += '\n\nOutput from run #%d:\n\n%s' % (
+ i, persisted_outputs[i])
+ print output_formatted
+
+ if self._output_chartjson_data:
+ with file(self._output_chartjson_data, 'w') as f:
+ f.write(persisted_result['chartjson'])
+
+ if self._get_output_dir_archive:
+ if persisted_result['archive_bytes'] is not None:
+ with file(self._get_output_dir_archive, 'wb') as f:
+ f.write(persisted_result['archive_bytes'])
+ else:
+ logging.error('The output dir was not archived.')
+
+ return persisted_result['exit_code']
+
+ #override
+ def TestType(self):
+ return 'Perf'
+

Powered by Google App Engine
This is Rietveld 408576698