mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core&judge: allow performance mode
This commit is contained in:
1 parent
080621738e
commit
4adf05c50b
5 files changed
+41
-32
No files matched your search
@@ -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');
|
||||
|
||||
@@ -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,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 = {};
|
||||
|
||||
Reference in new issue
Block a user