mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-21 01:46:28 +08:00
judge: optimize
This commit is contained in:
3 files changed
+37
-97
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user