diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-01-05 18:07:53 +0100 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-01-05 18:09:46 +0100 |
commit | 270e48158e3fec151c4be8bbacab483393fcc5e1 (patch) | |
tree | 2d7a902e871b1e6519d419255caba9d20c8cd133 /monkey | |
parent | 547b44c17b058e5605b31fb8b86abf9b2b894608 (diff) |
monkey.edits: cache test results
Diffstat (limited to 'monkey')
-rw-r--r-- | monkey/edits.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/monkey/edits.py b/monkey/edits.py index f087074..829fcb6 100644 --- a/monkey/edits.py +++ b/monkey/edits.py @@ -207,6 +207,11 @@ if __name__ == '__main__': ] edits, submissions, queries = {}, {}, {} + try: + test_results = pickle.load(open('test_results.pickle', 'rb')) + except: + test_results = collections.defaultdict(dict) + for problem in Problem.list(): pid = problem.id solutions = [s for s in Solution.filter(problem_id=pid, done=True) @@ -226,8 +231,15 @@ if __name__ == '__main__': dependencies = sorted([p[2:] for p in other_problems if p.identifier in used_predicate_identifiers]) + # Check for cached results. + normal_code = stringify(rename_vars(tokenize(code))) + code_key = (normal_code, tuple(dependencies)) + if code_key in test_results[pid]: + return test_results[pid][code_key] + aux_code = '\n' + solutions_for_problems('prolog', dependencies) + '\n' + facts correct, hints = problem_module.test(code, aux_code) + test_results[pid][code_key] = correct return correct print('Analyzing traces for {}… '.format(problem.identifier), end='', flush=True) @@ -241,3 +253,4 @@ if __name__ == '__main__': traceback.print_exc() pickle.dump((edits, submissions, queries), open('edits.pickle', 'wb')) + pickle.dump(test_results, open('test_results.pickle', 'wb')) |