From 37f8675f0695f967ba4b04ec0e7a935513271c26 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Sun, 27 Sep 2020 01:56:48 -0500 Subject: [PATCH] Boost loading testcases speed and increase submission limit --- dmoj/settings.py | 4 ++-- judge/views/submission.py | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dmoj/settings.py b/dmoj/settings.py index d7c1aaa..33dc3b9 100644 --- a/dmoj/settings.py +++ b/dmoj/settings.py @@ -67,7 +67,7 @@ DMOJ_EMAIL_THROTTLING = (10, 60) DMOJ_STATS_LANGUAGE_THRESHOLD = 10 DMOJ_SUBMISSIONS_REJUDGE_LIMIT = 10 # Maximum number of submissions a single user can queue without the `spam_submission` permission -DMOJ_SUBMISSION_LIMIT = 2 +DMOJ_SUBMISSION_LIMIT = 3 DMOJ_BLOG_NEW_PROBLEM_COUNT = 7 DMOJ_BLOG_RECENTLY_ATTEMPTED_PROBLEMS_COUNT = 7 DMOJ_TOTP_TOLERANCE_HALF_MINUTES = 1 @@ -500,7 +500,7 @@ try: except IOError: pass -TESTCASE_VISIBLE_LENGTH = 60 +TESTCASE_VISIBLE_LENGTH = 64 DATA_UPLOAD_MAX_NUMBER_FIELDS = 10240 DATA_UPLOAD_MAX_MEMORY_SIZE = 2621440 diff --git a/judge/views/submission.py b/judge/views/submission.py index 0d4fc4f..4848eb7 100644 --- a/judge/views/submission.py +++ b/judge/views/submission.py @@ -137,6 +137,11 @@ def group_test_cases(cases): return result +def read_head_archive(archive, file): + with archive.open(file) as f: + return f.read(settings.TESTCASE_VISIBLE_LENGTH + 3) + + def get_visible_content(data): data = data or b'' data = data.replace(b'\r\n', b'\r').replace(b'\r', b'\n') @@ -151,9 +156,9 @@ def get_visible_content(data): def get_input_answer(case, archive): result = {'input': '', 'answer': ''} if (len(case.input_file)): - result['input'] = get_visible_content(archive.read(case.input_file)) + result['input'] = get_visible_content(read_head_archive(archive, case.input_file)) if (len(case.output_file)): - result['answer'] = get_visible_content(archive.read(case.output_file)) + result['answer'] = get_visible_content(read_head_archive(archive, case.output_file)) return result