diff --git a/res/test.html b/res/test.html index 49134f6..91835e8 100644 --- a/res/test.html +++ b/res/test.html @@ -166,7 +166,9 @@

Scoring

Message

${res.data.message}

Run Info

-

Time: ${res.data.time}, Memory: ${res.data.memory}

+

Time: ${res.data.time}ms, Memory: ${ + res.data.memory + }KB

` ) if (res.type === 'JUDGE_PROGRESS') @@ -256,10 +258,9 @@

State

card.className = 'mdc-card mdc-card--outlined card' document.querySelector('.container').prepend(card) mdc.ripple.MDCRipple.attachTo(body) - const linearProgress = new mdc.linearProgress.MDCLinearProgress( + mdcProgress[id] = new mdc.linearProgress.MDCLinearProgress( document.getElementById(`progress-${id}`) ) - mdcProgress[id] = linearProgress return card } diff --git a/src/runner/cpp.ts b/src/runner/cpp.ts index 5b41179..0529c84 100644 --- a/src/runner/cpp.ts +++ b/src/runner/cpp.ts @@ -46,7 +46,7 @@ export default function ( const result = await execute( `p-${data.uid}`, getLimitString( - { cpuLimit: 6 }, + { cpuLimit: 50 }, `g++ ${tmpPath}/main.cpp -o ${exePath} -O2 -Wall -lm --static -pipe -std=c++17` ) ) diff --git a/src/runner/util.ts b/src/runner/util.ts index aae371d..c82f84d 100644 --- a/src/runner/util.ts +++ b/src/runner/util.ts @@ -23,7 +23,7 @@ export function execute( const child = spawn(`su`, [userName, '-c', exePath], { stdio: ['pipe', 'pipe', 'pipe'], }) - child.stdin.on('error', (err) => { + child.stdin.on('error', () => { resolve({ resultType: ResultType.stdioError, code: -1, @@ -31,7 +31,7 @@ export function execute( stderr: '', }) }) - child.on('error', (err) => { + child.on('error', () => { resolve({ resultType: ResultType.stdioError, code: -1, @@ -40,9 +40,11 @@ export function execute( }) }) - let timeHandler: NodeJS.Timeout + let timeHandler: NodeJS.Timeout, + timeouted = false if (timeout) timeHandler = setTimeout(() => { + timeouted = true child.kill() resolve({ resultType: ResultType.timeLimitExceeded, @@ -67,6 +69,7 @@ export function execute( }) child.on('close', (code) => { + if (timeouted) return if (timeHandler) clearTimeout(timeHandler) resolve({ resultType: ResultType.normal, @@ -125,7 +128,7 @@ export function getLimitString( limit.memoryLimit * 1024 };` : '' - }${limit.cpuLimit ? `cpulimit -l ${limit.cpuLimit} -- ` : ''}${command}` + }${limit.cpuLimit ? `cpulimit -i -l ${limit.cpuLimit} -- ` : ''}${command}` } export function executeJudge( @@ -136,7 +139,7 @@ export function executeJudge( return execute( `p-${data.uid}`, getLimitString( - { memoryLimit: data.memoryLimit, cpuLimit: 6 }, + { memoryLimit: data.memoryLimit, cpuLimit: 10 }, `/usr/bin/time -f "%E|%M" ${exePath}` ), input,