core&judge: allow performance mode

This commit is contained in:
undefined committed 2023-02-24 19:26:41 +08:00
1 parent 080621738e
commit 4adf05c50b
5 files changed
+41 -32

No files matched your search

+1
View File
@@ -26,6 +26,7 @@ const JudgeSettings = Schema.object({
secret: Schema.string().description('Judge Token Secret').default(String.random(32)),
disable: Schema.boolean().description('Disable builtin judge').default(false),
detail: Schema.boolean().description('Show diff detail').default(true),
performance: Schema.boolean().description('Performance mode').default(false),
});
const oldPath = path.resolve(os.homedir(), '.config', 'hydro', 'judge.yaml');
+7 -1
View File
@@ -155,13 +155,19 @@ export default class Hydro {
getNext(t: JudgeTask) {
return (data: Partial<JudgeResultBody>) => {
log.debug('Next: %o', data);
this.send(t.request.rid, 'next', data);
if (getConfig('performance') && data.case && !data.compilerText && !data.message) {
t.callbackCache ||= [];
t.callbackCache.push(data.case);
} else {
this.send(t.request.rid, 'next', data);
}
};
}
getEnd(t: JudgeTask) {
return (data: Partial<JudgeResultBody>) => {
log.info('End: %o', data);
if (t.callbackCache) data.cases = t.callbackCache;
this.send(t.request.rid, 'end', data);
};
}
+2 -1
View File
@@ -2,7 +2,7 @@ import fs from 'fs-extra';
import { LangConfig } from '@hydrooj/utils/lib/lang';
import { STATUS } from '@hydrooj/utils/lib/status';
import type {
FileInfo, JudgeMeta, JudgeRequest, JudgeResultBody,
FileInfo, JudgeMeta, JudgeRequest, JudgeResultBody, TestCase,
} from 'hydrooj';
import readCases from './cases';
import { getConfig } from './config';
@@ -40,6 +40,7 @@ export class JudgeTask {
next: (data: Partial<JudgeResultBody>) => void;
end: (data: Partial<JudgeResultBody>) => void;
env: Record<string, string>;
callbackCache?: TestCase[];
constructor(public session: Session, public request: JudgeRequest) {
this.stat = {};