Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cpu/wall time selection and simple form optimizations #170

Merged
merged 7 commits into from
Jan 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed public/public/term_cyr.ttf
Binary file not shown.
121 changes: 102 additions & 19 deletions src/components/Submissions/TestResultsTable/TestResultsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import exitCodeMapping from '../../helpers/exitCodeMapping';
const hasValue = value => value !== null;

const tickOrCrossAndRatioOrValue = (isOK, ratio, value, pretty, multiplier) =>
<td
<span
className={classNames({
'text-center': true,
'text-success': isOK,
Expand All @@ -32,7 +32,81 @@ const tickOrCrossAndRatioOrValue = (isOK, ratio, value, pretty, multiplier) =>
{hasValue(value) && ') '}
{hasValue(value) && pretty(value * multiplier)}
</small>
</td>;
</span>;

const showTimeResults = (
key,
wallTime,
wallTimeRatio,
wallTimeExceeded,
cpuTime,
cpuTimeRatio,
cpuTimeExceeded
) => {
const showWall =
Boolean(wallTimeRatio) || (wallTimeExceeded && !cpuTimeExceeded);
const showCpu = Boolean(cpuTimeRatio) || cpuTimeExceeded || !showWall;
return (
<table style={{ display: 'inline-block' }}>
<tbody>
{showCpu &&
<tr>
<td className="text-muted">
<OverlayTrigger
placement="top"
overlay={
<Tooltip id="wall-time-icon">
<FormattedMessage
id="app.submissions.testResultsTable.cpuTimeExplain"
defaultMessage="CPU time (total time the CPU was used by all threads)"
/>
</Tooltip>
}
>
<Icon name="microchip" style={{ marginRight: '10px' }} />
</OverlayTrigger>
</td>
<td className="text-left">
{tickOrCrossAndRatioOrValue(
cpuTimeExceeded === false,
cpuTimeRatio,
cpuTime,
prettyMs,
1000
)}
</td>
</tr>}
{showWall &&
<tr>
<td className="text-muted">
<OverlayTrigger
placement="top"
overlay={
<Tooltip id="wall-time-icon">
<FormattedMessage
id="app.submissions.testResultsTable.wallTimeExplain"
defaultMessage="Wall time (real-time measured by external clock)"
/>
</Tooltip>
}
>
<Icon name="clock-o" style={{ marginRight: '10px' }} />
</OverlayTrigger>
</td>
<td className="text-left">
{tickOrCrossAndRatioOrValue(
wallTimeExceeded === false,
wallTimeRatio,
wallTime,
prettyMs,
1000
)}
</td>
</tr>}
</tbody>
</table>
);
};

const TestResultsTable = ({ results, runtimeEnvironmentId }) =>
<Table responsive>
Expand Down Expand Up @@ -85,7 +159,7 @@ const TestResultsTable = ({ results, runtimeEnvironmentId }) =>
>
<span>
<Icon name="thermometer-half" />&nbsp;&nbsp;
<Icon name="microchip" />
<Icon name="braille" />
</span>
</OverlayTrigger>
</th>
Expand Down Expand Up @@ -133,11 +207,14 @@ const TestResultsTable = ({ results, runtimeEnvironmentId }) =>
status,
memoryExceeded,
wallTimeExceeded,
cpuTimeExceeded,
message,
wallTimeRatio,
memoryRatio,
wallTime,
wallTimeRatio,
cpuTimeRatio,
memory,
wallTime,
cpuTime,
exitCode
}) =>
<tr key={testName}>
Expand Down Expand Up @@ -181,20 +258,26 @@ const TestResultsTable = ({ results, runtimeEnvironmentId }) =>
</b>
</td>

{tickOrCrossAndRatioOrValue(
memoryExceeded === false,
memoryRatio,
memory,
prettyPrintBytes,
1024
)}
{tickOrCrossAndRatioOrValue(
wallTimeExceeded === false,
wallTimeRatio,
wallTime,
prettyMs,
1000
)}
<td className="text-center">
{tickOrCrossAndRatioOrValue(
memoryExceeded === false,
memoryRatio,
memory,
prettyPrintBytes,
1024
)}
</td>
<td className="text-center">
{showTimeResults(
testName,
wallTime,
wallTimeRatio,
wallTimeExceeded,
cpuTime,
cpuTimeRatio,
cpuTimeExceeded
)}
</td>

<td className="text-center">
{exitCodeMapping(runtimeEnvironmentId, exitCode)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Box from '../../../components/widgets/Box';
import SubmitButton from '../SubmitButton';
import EditExerciseConfigEnvironment from './EditExerciseConfigEnvironment';
import { fetchSupplementaryFilesForExercise } from '../../../redux/modules/supplementaryFiles';
import { createGetSupplementaryFiles } from '../../../redux/selectors/supplementaryFiles';
import { getSupplementaryFilesForExercise } from '../../../redux/selectors/supplementaryFiles';
import { getVariablesForPipelines } from '../../../redux/modules/exercises';

class EditExerciseConfigForm extends Component {
Expand Down Expand Up @@ -327,11 +327,8 @@ const validate = ({ config }) => {

const ConnectedEditExerciseConfigForm = connect(
(state, { exercise }) => {
const getSupplementaryFilesForExercise = createGetSupplementaryFiles(
exercise.supplementaryFilesIds
);
return {
supplementaryFiles: getSupplementaryFilesForExercise(state),
supplementaryFiles: getSupplementaryFilesForExercise(exercise.id)(state),
formValues: getFormValues('editExerciseConfig')(state)
};
},
Expand Down
Loading