summaryrefslogtreecommitdiff
path: root/monkey
diff options
context:
space:
mode:
Diffstat (limited to 'monkey')
-rw-r--r--monkey/edits.py13
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'))