Skip to content

Commit 8cdbc22

Browse files
committed
ci: move g++ warmup from test code to CI workflow
Cold-start mitigation belongs in the CI layer, not in test code. The workflow now runs g++ before tests so the toolchain is already in the OS file cache. Also removes QStandardPaths/QProcess dependency that was only needed for the warmup.
1 parent 3c5eebc commit 8cdbc22

2 files changed

Lines changed: 10 additions & 14 deletions

File tree

.github/workflows/windows-qt6.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ jobs:
8080
- name: Deploy Qt for tests
8181
shell: pwsh
8282
run: windeployqt tests\test1\test1.exe
83+
- name: Warm up g++ (cold-start mitigation)
84+
shell: bash
85+
run: |
86+
gpp=$(which g++ 2>/dev/null || true)
87+
if [ -n "$gpp" ]; then
88+
echo "int main(){return 0;}" | g++ -x c++ -O2 -o "$TEMP/_warmup.exe" -
89+
echo "g++ warmup done: $gpp"
90+
else
91+
echo "g++ not found, skipping warmup"
92+
fi
8393
- name: Run tests
8494
shell: bash
8595
env:

tests/test1/main.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,20 +159,6 @@ class TestContest : public QObject {
159159
}
160160
};
161161
copyDir(m_contestDir, dst, copyDir);
162-
163-
// Warm up g++: compile a trivial program to pay the cold-start cost
164-
// upfront instead of during the timed judging test.
165-
{
166-
QString gppPath = QStandardPaths::findExecutable("g++");
167-
if (!gppPath.isEmpty()) {
168-
QProcess warmup;
169-
warmup.start(gppPath, {"-x", "c++", "-O2", "-o",
170-
m_tempWorkDir.path() + "/_warmup.exe", "-"});
171-
warmup.write("int main(){return 0;}");
172-
warmup.closeWriteChannel();
173-
warmup.waitForFinished(60000);
174-
}
175-
}
176162
}
177163

178164
// ------------------------------------------------------------------

0 commit comments

Comments
 (0)