Browse Source

Change the style of showing memory usage

pull/6/head
Menci 6 years ago
parent
commit
3032463faf
  1. 3
      libs/submissions_process.js
  2. 4
      utility.js
  3. 8
      views/submissions_item.ejs

3
libs/submissions_process.js

@ -18,7 +18,8 @@ const getRoughResult = (x, displayConfig) => {
return { return {
result: x.status, result: x.status,
time: displayConfig.showUsage ? x.total_time : null, time: displayConfig.showUsage ? x.total_time : null,
memory: displayConfig.showUsage ? x.max_memory : null, memory: displayConfig.showUsage ? syzoj.utils.formatSize((x.max_memory * 1024) || 0, 2) : null,
precise_memory: displayConfig.showUsage ? x.max_memory : null,
score: displayConfig.showScore ? x.score : null score: displayConfig.showScore ? x.score : null
}; };
} }

4
utility.js

@ -121,8 +121,8 @@ module.exports = {
} }
return sgn + util.format('%s:%s:%s', toStringWithPad(x / 3600), toStringWithPad(x / 60 % 60), toStringWithPad(x % 60)); return sgn + util.format('%s:%s:%s', toStringWithPad(x / 3600), toStringWithPad(x / 60 % 60), toStringWithPad(x % 60));
}, },
formatSize(x) { formatSize(x, precision) {
let res = filesize(x, { fixed: 1 }).calculate(); let res = filesize(x, { fixed: precision || 1 }).calculate();
if (res.result === parseInt(res.result)) res.fixed = res.result.toString(); if (res.result === parseInt(res.result)) res.fixed = res.result.toString();
if (res.suffix.startsWith('Byte')) res.suffix = 'B'; if (res.suffix.startsWith('Byte')) res.suffix = 'B';
else res.suffix = res.suffix.replace('iB', ''); else res.suffix = res.suffix.replace('iB', '');

8
views/submissions_item.ejs

@ -69,7 +69,13 @@ Vue.component('submission-item', {
<td v-if="config.showScore"><span class="score" :class="scoreClass">{{ Math.floor(data.result.score || 0) }}</span></td> <td v-if="config.showScore"><span class="score" :class="scoreClass">{{ Math.floor(data.result.score || 0) }}</span></td>
<% } %> <% } %>
<td v-if="config.showUsage">{{ (data.result.time || 0).toString() + ' ms' }}</td> <td v-if="config.showUsage">{{ (data.result.time || 0).toString() + ' ms' }}</td>
<td v-if="config.showUsage">{{ (data.result.memory || 0).toString() + ' KiB' }}</td>
<% if (active === 'submissions') { %>
<td v-if="config.showUsage">{{ data.result.memory }}</td>
<% } else { %>
<td v-if="config.showUsage">{{ (data.result.precise_memory || 0).toString() + ' K'}}</td>
<% } %>
</template> <template v-else> </template> <template v-else>
<td v-if="config.showScore"/> <td v-if="config.showUsage"/> <td v-if="config.showUsage"/> <td v-if="config.showScore"/> <td v-if="config.showUsage"/> <td v-if="config.showUsage"/>
</template> </template>

Loading…
Cancel
Save