judge: performance upgrade

This commit is contained in:
undefined committed 2023-11-25 04:26:09 +08:00
1 parent 607230c09e
commit 1f2f06c3f2
2 files changed
+43 -20

No files matched your search

+7 -5
View File
@@ -3,7 +3,7 @@
import path from 'path';
import { fs } from '@hydrooj/utils';
import {
JudgeResultBody, RecordModel, SettingModel,
JudgeResultBody, ObjectId, RecordModel, SettingModel,
StorageModel, SystemModel, TaskModel,
} from 'hydrooj';
import { end, next } from 'hydrooj/src/handler/judge';
@@ -23,19 +23,21 @@ const session = {
return target;
},
getNext(t: Context) {
return (data: Partial<JudgeResultBody>) => {
return async (data: Partial<JudgeResultBody>) => {
logger.debug('Next: %o', data);
data.rid = t.rid as any;
const rdoc = await RecordModel.get(new ObjectId(t.rid));
if (data.case) data.case.message ||= '';
next(data);
next({ ...data, rdoc });
};
},
getEnd(t: Context) {
return (data: Partial<JudgeResultBody>) => {
return async (data: Partial<JudgeResultBody>) => {
data.key = 'end';
data.rid = t.rid as any;
const rdoc = await RecordModel.get(new ObjectId(t.rid));
logger.info('End: status=%d score=%d time=%dms memory=%dkb', data.status, data.score, data.time, data.memory);
end(data);
end({ ...data, rdoc });
};
},
getLang(lang: string, doThrow = true) {