judge: optimize

This commit is contained in:
undefined committed 2023-11-23 10:24:35 +08:00
1 parent 2d25eaac0f
commit 0bc6a28457
3 files changed
+37 -97

No files matched your search

+27 -2
View File
@@ -10,10 +10,10 @@ import checkers from './checkers';
import compile, { compileWithTestlib } from './compile';
import { getConfig } from './config';
import { CompileError, FormatError } from './error';
import { NextFunction, ParsedConfig } from './interface';
import { Execute, NextFunction, ParsedConfig } from './interface';
import judge from './judge';
import { Logger } from './log';
import { CopyIn, CopyInFile } from './sandbox';
import { CopyIn, CopyInFile, runQueued } from './sandbox';
import { compilerText, md5 } from './utils';
interface Session {
@@ -156,4 +156,29 @@ export class JudgeTask {
this.clean.push(result.clean);
return result;
}
async runAnalysis(execute: Execute, input: CopyInFile) {
const langConfig = this.session.getLang(this.lang);
if (!langConfig.analysis) return;
try {
const r = await runQueued(langConfig.analysis, {
copyIn: {
...execute.copyIn,
input,
[langConfig.code_file || 'foo']: this.code,
compile: { content: langConfig.compile || '' },
execute: { content: langConfig.execute || '' },
},
env: this.env,
time: 5000,
memory: 256,
});
const out = r.stdout.toString();
if (out.length) this.next({ compilerText: out.substring(0, 1024) });
if (process.env.DEV) console.log(r);
} catch (e) {
logger.info('Failed to run analysis');
logger.error(e);
}
}
}