diff options
author | Guang Zhu <guangzhu@google.com> | 2009-06-10 13:37:03 -0700 |
---|---|---|
committer | Guang Zhu <guangzhu@google.com> | 2009-06-10 13:37:03 -0700 |
commit | 2ab6f1fe0b17d281ea215f8ca412a5e1992011cc (patch) | |
tree | a7335c6f74566e77daeaa5c9833f7073dd3fa83d /tests/DumpRenderTree/assets | |
parent | 137c45036699eeceb061a47ab14d9a7eb860674d (diff) | |
download | frameworks_base-2ab6f1fe0b17d281ea215f8ca412a5e1992011cc.zip frameworks_base-2ab6f1fe0b17d281ea215f8ca412a5e1992011cc.tar.gz frameworks_base-2ab6f1fe0b17d281ea215f8ca412a5e1992011cc.tar.bz2 |
Added support to record page load time for each url.
Diffstat (limited to 'tests/DumpRenderTree/assets')
-rwxr-xr-x | tests/DumpRenderTree/assets/run_reliability_tests.py | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/tests/DumpRenderTree/assets/run_reliability_tests.py b/tests/DumpRenderTree/assets/run_reliability_tests.py index 076c508..b038740 100755 --- a/tests/DumpRenderTree/assets/run_reliability_tests.py +++ b/tests/DumpRenderTree/assets/run_reliability_tests.py @@ -18,6 +18,7 @@ import time TEST_LIST_FILE = "/sdcard/android/reliability_tests_list.txt" TEST_STATUS_FILE = "/sdcard/android/reliability_running_test.txt" TEST_TIMEOUT_FILE = "/sdcard/android/reliability_timeout_test.txt" +TEST_LOAD_TIME_FILE = "/sdcard/android/reliability_load_time.txt" HTTP_URL_FILE = "urllist_http" HTTPS_URL_FILE = "urllist_https" NUM_URLS = 25 @@ -62,6 +63,36 @@ def Bugreport(url, bugreport_dir, adb_cmd): os.system(cmd) +def ProcessPageLoadTime(raw_log): + """Processes the raw page load time logged by test app.""" + log_handle = open(raw_log, "r") + load_times = {} + + for line in log_handle: + line = line.strip() + pair = line.split("|") + if len(pair) != 2: + logging.info("Line has more than one '|': " + line) + continue + if pair[0] not in load_times: + load_times[pair[0]] = [0, 0] + try: + pair[1] = int(pair[1]) + except ValueError: + logging.info("Lins has non-numeric load time: " + line) + continue + load_times[pair[0]][0] += pair[1] + load_times[pair[0]][1] += 1 + + log_handle.close() + + # rewrite the average time to file + log_handle = open(raw_log, "w") + for url, times in load_times.iteritems(): + log_handle.write("%s|%f\n" % (url, float(times[0]) / times[1])) + log_handle.close() + + def main(options, args): """Send the url list to device and start testing, restart if crashed.""" @@ -141,8 +172,13 @@ def main(options, args): # Call ReliabilityTestsAutoTest#startReliabilityTests test_cmd = (test_cmd_prefix + " -e class " "com.android.dumprendertree.ReliabilityTest#" - "runReliabilityTest -e timeout %s -e delay %s %s" % - (str(timeout_ms), str(manual_delay), test_cmd_postfix)) + "runReliabilityTest -e timeout %s -e delay %s" % + (str(timeout_ms), str(manual_delay))) + + if options.logtime: + test_cmd += " -e logtime true" + + test_cmd += test_cmd_postfix adb_output = subprocess.Popen(test_cmd, shell=True, stdout=subprocess.PIPE, @@ -176,12 +212,20 @@ def main(options, args): else: logging.info("No crash found.") + # get timeout file from sdcard test_cmd = (adb_cmd + "pull \"" + TEST_TIMEOUT_FILE + "\" \"" + timedout_file + "\"") - subprocess.Popen(test_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + if options.logtime: + # get logged page load times from sdcard + test_cmd = (adb_cmd + "pull \"" + TEST_LOAD_TIME_FILE + "\" \"" + + options.logtime + "\"") + subprocess.Popen(test_cmd, shell=True, stdout=subprocess.PIPE, + stderr=subprocess.PIPE).communicate() + ProcessPageLoadTime(options.logtime) + if "__main__" == __name__: option_parser = optparse.OptionParser() @@ -206,5 +250,8 @@ if "__main__" == __name__: option_parser.add_option("-b", "--bugreport", default=".", help="the directory to store bugreport for crashes") + option_parser.add_option("-l", "--logtime", + default=None, + help="Logs page load time for each url to the file") opts, arguments = option_parser.parse_args() main(opts, arguments) |