Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/python | |
| 2 | |
| 3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 4 # for details. All rights reserved. Use of this source code is governed by a | |
| 5 # BSD-style license that can be found in the LICENSE file. | |
| 6 | |
| 7 from create_graph import BROWSER_CORRECTNESS | |
| 8 from create_graph import BrowserCorrectnessTest | |
| 9 from create_graph import BROWSER_PERF | |
| 10 from create_graph import BrowserPerformanceTest | |
| 11 from create_graph import CL_PERF | |
| 12 from create_graph import CommandLinePerformanceTest | |
| 13 from create_graph import CompileTimeAndSizeTest | |
| 14 from create_graph import TIME_SIZE | |
| 15 | |
| 16 import os | |
| 17 from os.path import dirname, abspath | |
| 18 import pickle | |
| 19 import re | |
| 20 import sys | |
| 21 | |
| 22 """Find the most recent performance files, and store the stats.""" | |
| 23 | |
| 24 # TODO(efortuna): turn these into proper appengine tasks, using the app engine | |
| 25 # datastore instead of files. | |
| 26 | |
| 27 DIRECTORIES = [BROWSER_CORRECTNESS, BROWSER_PERF, CL_PERF, TIME_SIZE] | |
| 28 PICKLE_FILENAME = 'start_stats.txt' | |
| 29 | |
| 30 def find_latest_data_files(directory): | |
| 31 """Given a directory, find the files with the latest timestamp, indicating the | |
| 32 latest results. | |
| 33 | |
| 34 Args: | |
| 35 directory: name of the directory we should look inside. | |
| 36 | |
| 37 Returns: | |
| 38 A list of the most recent files in the particular directory.""" | |
| 39 path = dirname(abspath(__file__)) | |
| 40 files = os.listdir(os.path.join(path, directory)) | |
| 41 files.sort() | |
| 42 f = files.pop() | |
| 43 match = re.search('[1-9]', f) | |
| 44 trace_name = f[:match.start()] | |
| 45 timestamp_and_data = f[match.start():] | |
| 46 latest_files = [f] | |
| 47 if trace_name == 'correctness' or trace_name == 'perf-': | |
| 48 index = timestamp_and_data.find('-') | |
| 49 timestamp = timestamp_and_data[:index] | |
| 50 f = files.pop() | |
| 51 while f[match.start() : match.start() + index] == timestamp: | |
| 52 latest_files.append(f) | |
| 53 f = files.pop() | |
| 54 return latest_files | |
| 55 | |
| 56 def populate_stats_dict(test_runner_dict = None): | |
| 57 """Find the latest files in each directory, and process those latest files | |
| 58 using the appropriate TestRunner. | |
| 59 | |
| 60 Args: | |
| 61 test_runner_dict: optional agument to which we should """ | |
|
Siggi Cherem (dart-lang)
2012/01/26 19:19:53
extra period at the end of the sentence.
| |
| 62 cur_runner_dict = dict() | |
| 63 if test_runner_dict: | |
| 64 cur_runner_dict = test_runner_dict | |
| 65 for directory in DIRECTORIES: | |
| 66 test_runner = None | |
| 67 latest_files = find_latest_data_files(directory) | |
| 68 | |
| 69 if test_runner_dict: | |
| 70 test_runner = cur_runner_dict[directory] | |
| 71 else: | |
| 72 if directory == BROWSER_CORRECTNESS: | |
| 73 test_runner = BrowserCorrectnessTest('language', directory) | |
| 74 elif directory == BROWSER_PERF: | |
| 75 test_runner = BrowserPerformanceTest(directory) | |
| 76 elif directory == TIME_SIZE: | |
| 77 test_runner = CompileTimeAndSizeTest(directory) | |
| 78 elif directory == CL_PERF: | |
| 79 test_runner = CommandLinePerformanceTest(directory) | |
| 80 cur_runner_dict[directory] = test_runner | |
| 81 | |
| 82 for f in latest_files: | |
| 83 test_runner.process_file(f) | |
| 84 return cur_runner_dict | |
| 85 | |
| 86 def main(): | |
| 87 test_runner_dict = populate_stats_dict() | |
| 88 f = open(PICKLE_FILENAME, 'w') | |
| 89 pickle.dump(test_runner_dict, f) | |
| 90 f.close() | |
| 91 | |
| 92 if __name__ == '__main__': | |
| 93 main() | |
| OLD | NEW |