| 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 storing previous data in runners to which |
| 62 we should add our data.""" |
| 63 cur_runner_dict = dict() |
| 64 if test_runner_dict: |
| 65 cur_runner_dict = test_runner_dict |
| 66 for directory in DIRECTORIES: |
| 67 test_runner = None |
| 68 latest_files = find_latest_data_files(directory) |
| 69 |
| 70 if test_runner_dict: |
| 71 test_runner = cur_runner_dict[directory] |
| 72 else: |
| 73 if directory == BROWSER_CORRECTNESS: |
| 74 test_runner = BrowserCorrectnessTest('language', directory) |
| 75 elif directory == BROWSER_PERF: |
| 76 test_runner = BrowserPerformanceTest(directory) |
| 77 elif directory == TIME_SIZE: |
| 78 test_runner = CompileTimeAndSizeTest(directory) |
| 79 elif directory == CL_PERF: |
| 80 test_runner = CommandLinePerformanceTest(directory) |
| 81 cur_runner_dict[directory] = test_runner |
| 82 |
| 83 for f in latest_files: |
| 84 test_runner.process_file(f) |
| 85 return cur_runner_dict |
| 86 |
| 87 def main(): |
| 88 test_runner_dict = populate_stats_dict() |
| 89 f = open(PICKLE_FILENAME, 'w') |
| 90 pickle.dump(test_runner_dict, f) |
| 91 f.close() |
| 92 |
| 93 if __name__ == '__main__': |
| 94 main() |
| OLD | NEW |