Skip to content
Merged
7 changes: 7 additions & 0 deletions src/base/LemonUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ namespace Lemon::detail {
} else
return -1;
}
inline qint64 jsonReadHelper(qint64 &val, const QJsonValue &jval) {
if (jval.isDouble()) {
val = jval.toInteger();
return 0;
} else
return -1;
}
inline int jsonReadHelper(bool &val, const QJsonValue &jval) {
if (jval.isBool()) {
val = jval.toBool();
Expand Down
4 changes: 2 additions & 2 deletions src/component/exportutil/exportutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ auto ExportUtil::getContestantHtmlCode(Contest *contest, Contestant *contestant,
QList<QList<ResultState>> result = contestant->getResult(i);
QList<QStringList> message = contestant->getMessage(i);
QList<QList<int>> timeUsed = contestant->getTimeUsed(i);
QList<QList<int>> memoryUsed = contestant->getMemoryUsed(i);
QList<QList<qint64>> memoryUsed = contestant->getMemoryUsed(i);
QList<QList<int>> score = contestant->getScore(i);

for (int j = 0; j < inputFiles.size(); j++) {
Expand Down Expand Up @@ -493,7 +493,7 @@ auto ExportUtil::getSmallerContestantHtmlCode(Contest *contest, Contestant *cont
QList<QList<ResultState>> result = contestant->getResult(i);
QList<QStringList> message = contestant->getMessage(i);
QList<QList<int>> timeUsed = contestant->getTimeUsed(i);
QList<QList<int>> memoryUsed = contestant->getMemoryUsed(i);
QList<QList<qint64>> memoryUsed = contestant->getMemoryUsed(i);
QList<QList<int>> score = contestant->getScore(i);

for (int j = 0; j < inputFiles.size(); j++) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/contest.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Contest : public QObject {
void taskDeletedForViewer(int);
void problemTitleChanged();
void dialogAlert(QString);
void singleCaseFinished(QString, int, int, int, int, int, int, int);
void singleCaseFinished(QString, int, int, int, int, int, int, qint64);
void singleSubtaskDependenceFinished(int, int, int);
void taskJudgingStarted(QString);
void taskJudgingFinished();
Expand Down
21 changes: 17 additions & 4 deletions src/core/contestant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ auto Contestant::getScore(int index) const -> const QList<QList<int>> & { return

auto Contestant::getTimeUsed(int index) const -> const QList<QList<int>> & { return timeUsed[index]; }

auto Contestant::getMemoryUsed(int index) const -> const QList<QList<int>> & { return memoryUsed[index]; }
auto Contestant::getMemoryUsed(int index) const -> const QList<QList<qint64>> & { return memoryUsed[index]; }

auto Contestant::getJudingTime() const -> QDateTime { return judgingTime; }

Expand All @@ -60,7 +60,7 @@ void Contestant::setScore(int index, const QList<QList<int>> &_score) { score[in

void Contestant::setTimeUsed(int index, const QList<QList<int>> &_timeUsed) { timeUsed[index] = _timeUsed; }

void Contestant::setMemoryUsed(int index, const QList<QList<int>> &_memoryUsed) {
void Contestant::setMemoryUsed(int index, const QList<QList<qint64>> &_memoryUsed) {
memoryUsed[index] = _memoryUsed;
}

Expand All @@ -76,7 +76,7 @@ void Contestant::addTask() {
message.append(QList<QStringList>());
score.append(QList<QList<int>>());
timeUsed.append(QList<QList<int>>());
memoryUsed.append(QList<QList<int>>());
memoryUsed.append(QList<QList<qint64>>());
}

void Contestant::deleteTask(int index) {
Expand Down Expand Up @@ -236,7 +236,20 @@ void Contestant::readFromStream(QDataStream &in) {
in >> message;
in >> score;
in >> timeUsed;
in >> memoryUsed;
// memoryUsed 之前存储为 int 三维数组,现在改为了 qint64,因此先读取旧结构,再逐层转换
QList<QList<QList<int>>> oldMemoryUsed;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我是不是忘记 memoryUsed.clear(); 了😂

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

开了一个新的 #299

in >> oldMemoryUsed;
for (const auto &l1 : oldMemoryUsed) {
QList<QList<qint64>> newL1;
for (const auto &l2 : l1) {
QList<qint64> newL2;
for (int v : l2) {
newL2.append(v);
}
newL1.append(newL2);
}
memoryUsed.append(newL1);
}
quint32 judgingTime_date = 0;
quint32 judgingTime_time = 0;
quint8 judgingTime_timespec = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/core/contestant.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Contestant : public QObject {
const QList<QStringList> &getMessage(int) const;
const QList<QList<int>> &getScore(int) const;
const QList<QList<int>> &getTimeUsed(int) const;
const QList<QList<int>> &getMemoryUsed(int) const;
const QList<QList<qint64>> &getMemoryUsed(int) const;
QDateTime getJudingTime() const;
int getTaskScore(int) const;
int getTotalScore() const;
Expand All @@ -46,7 +46,7 @@ class Contestant : public QObject {
void setMessage(int, const QList<QStringList> &);
void setScore(int, const QList<QList<int>> &);
void setTimeUsed(int, const QList<QList<int>> &);
void setMemoryUsed(int, const QList<QList<int>> &);
void setMemoryUsed(int, const QList<QList<qint64>> &);
void setJudgingTime(QDateTime);

int writeToJson(QJsonObject &);
Expand All @@ -64,7 +64,7 @@ class Contestant : public QObject {
QList<QList<QStringList>> message;
QList<QList<QList<int>>> score;
QList<QList<QList<int>>> timeUsed;
QList<QList<QList<int>>> memoryUsed;
QList<QList<QList<qint64>>> memoryUsed;
QDateTime judgingTime;

// QList<TaskResult> taskResults;
Expand Down
4 changes: 2 additions & 2 deletions src/core/judgingthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void JudgingThread::setInterpreterAsWatcher(bool use) { interpreterAsWatcher = u

auto JudgingThread::getTimeUsed() const -> int { return timeUsed; }

auto JudgingThread::getMemoryUsed() const -> int { return memoryUsed; }
auto JudgingThread::getMemoryUsed() const -> qint64 { return memoryUsed; }

auto JudgingThread::getScore() const -> int { return score; }

Expand Down Expand Up @@ -828,4 +828,4 @@ void JudgingThread::run() {
judgeAnswersOnlyTask();
break;
}
}
}
4 changes: 2 additions & 2 deletions src/core/judgingthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class JudgingThread : public QThread {
void setRawMemoryLimit(int);
void setInterpreterAsWatcher(bool);
int getTimeUsed() const;
int getMemoryUsed() const;
qint64 getMemoryUsed() const;
int getScore() const;
int getFullScore() const;
int getJudgeTimes() const;
Expand Down Expand Up @@ -72,7 +72,7 @@ class JudgingThread : public QThread {
int memoryLimit{};
int rawMemoryLimit{};
int timeUsed;
int memoryUsed;
qint64 memoryUsed;
int score{};
int judgedTimes;
ResultState result;
Expand Down
2 changes: 1 addition & 1 deletion src/core/processrunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct ProcessRunnerResult {
ResultState result = CorrectAnswer;
int score = 0;
int timeUsed = -1;
int memoryUsed = -1;
qint64 memoryUsed = -1;
QString message;
};

Expand Down
5 changes: 3 additions & 2 deletions src/core/processrunner_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ ProcessRunnerResult WinProcessRunner::run() {
if (config.memoryLimit != -1) {
GetProcessMemoryInfo(pi.hProcess, (PROCESS_MEMORY_COUNTERS *)&memoryInfo, sizeof(memoryInfo));

if (qMax(memoryInfo.PrivateUsage, memoryInfo.PeakWorkingSetSize) > config.memoryLimit * 1024 * 1024) {
if (qMax(memoryInfo.PrivateUsage, memoryInfo.PeakWorkingSetSize) >
1ll * config.memoryLimit * 1024 * 1024) {
TerminateProcess(pi.hProcess, 0);

res.score = 0;
Expand All @@ -292,7 +293,7 @@ ProcessRunnerResult WinProcessRunner::run() {
GetProcessMemoryInfo(pi.hProcess, (PROCESS_MEMORY_COUNTERS *)&memoryInfo, sizeof(memoryInfo));

if (qMax(memoryInfo.PrivateUsage, memoryInfo.PeakWorkingSetSize) >
config.memoryLimit * 1024U * 1024) {
1ll * config.memoryLimit * 1024 * 1024) {
Comment thread
ZnPdCo marked this conversation as resolved.
TerminateProcess(pi.hProcess, 0);
res.score = 0;
res.result = MemoryLimitExceeded;
Expand Down
2 changes: 1 addition & 1 deletion src/core/taskjudger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ int TaskJudger::judge() {

for (int i = 0; i < task->getTestCaseList().size(); i++) {
timeUsed.append(QList<int>());
memoryUsed.append(QList<int>());
memoryUsed.append(QList<qint64>());
score.append(QList<int>());
result.append(QList<ResultState>());
overallStatus.append(maxDependValue);
Expand Down
4 changes: 2 additions & 2 deletions src/core/taskjudger.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class TaskJudger : public QObject {
QProcessEnvironment environment;
QList<int> overallStatus;
QList<QList<int>> timeUsed;
QList<QList<int>> memoryUsed;
QList<QList<qint64>> memoryUsed;
QList<QList<int>> score;
QList<QList<ResultState>> result;
QList<QStringList> message;
Expand All @@ -81,7 +81,7 @@ class TaskJudger : public QObject {
void judgingStarted(QString);
void judgingFinished();
void dialogAlert(QString);
void singleCaseFinished(QString, int, int, int, int, int, int, int);
void singleCaseFinished(QString, int, int, int, int, int, int, qint64);
void singleSubtaskDependenceFinished(int, int, int);
void compileError(int, int);
void stopJudgingSignal();
Expand Down
2 changes: 1 addition & 1 deletion src/detaildialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void DetailDialog::refreshViewer(Contest *_contest, Contestant *_contestant) {
QList<QList<ResultState>> result = contestant->getResult(i);
QList<QStringList> message = contestant->getMessage(i);
QList<QList<int>> timeUsed = contestant->getTimeUsed(i);
QList<QList<int>> memoryUsed = contestant->getMemoryUsed(i);
QList<QList<qint64>> memoryUsed = contestant->getMemoryUsed(i);
QList<QList<int>> score = contestant->getScore(i);

for (int j = 0; j < inputFiles.size(); j++) {
Expand Down
2 changes: 1 addition & 1 deletion src/judgingdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void JudgingDialog::judgeAll() {
}

void JudgingDialog::singleCaseFinished(QString contestantName, int progress, int x, int y, int result,
int scoreGot, int timeUsed, int memoryUsed) {
int scoreGot, int timeUsed, qint64 memoryUsed) {
bool isOnMaxValue =
ui->logViewer->verticalScrollBar()->value() == ui->logViewer->verticalScrollBar()->maximum();
QTextBlockFormat blockFormat;
Expand Down
2 changes: 1 addition & 1 deletion src/judgingdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class JudgingDialog : public QDialog {

public slots:
void dialogAlert(const QString &);
void singleCaseFinished(QString, int, int, int, int, int, int, int);
void singleCaseFinished(QString, int, int, int, int, int, int, qint64);
void singleSubtaskDependenceFinished(int, int, int);
void taskJudgingStarted(const QString &);
void taskJudgedDisplay(const QString &, const QList<QList<int>> &, const int);
Expand Down
Loading