Repository navigation
Run the xUnit v3 test executable directly (~35% faster) - #331
Conversation
dotnet test starts MSBuild and the VSTest host to run the same test executable, which costs about 3 s per run. The runner now builds with dotnet build and runs the executable itself, writing a TRX report. The executable escapes quotes and control characters in test names and failure messages, so the parser turns them back. Projects without a test executable (such as xUnit v2) still use dotnet test. Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The runner parses the tests with Fantomas.FCS, and without precompiled code the JIT compiles the parser on every run. Publishing with ReadyToRun takes the runner's own start-up and parsing from about 1.7 s to about 0.9 s. Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| # Fantomas.FCS) is precompiled and doesn't go through the JIT on every run. | ||
| COPY src/Exercism.TestRunner.FSharp/Exercism.TestRunner.FSharp.fsproj ./ | ||
| RUN dotnet restore -a $TARGETARCH | ||
| RUN dotnet restore -a $TARGETARCH -p:PublishReadyToRun=true |
There was a problem hiding this comment.
Set the PublishReadyToRun property in the project file such that you don't need to specify it here. See https://learn.microsoft.com/en-us/dotnet/core/deploying/ready-to-run
| if File.Exists(context.TestResultsFile) then | ||
| TestRunSuccess(TestResults.parse true originalTestCode originalTestTree context) | ||
| else | ||
| // Older projects (such as xUnit v2) don't build to a test executable, |
There was a problem hiding this comment.
Assume that all projects use xUnit 3. So simplify the code accordingly. See exercism/csharp-test-runner@a92e483 for how it can be done.
The Dockerfile's restore and publish no longer pass it, and use long argument names. Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
All 156 exercises in the track use xunit.v3 3.2.2, so the runner always runs the test executable and no longer falls back to dotnet test. If the executable writes no results file (for example because it crashed), the run now reports the error message, as the C# runner does. Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks Erik. Both points are done, and #332 is rebased on top.
I also applied your C# feedback to #332, which has its own shape generator. The Python script is now a C# program in I checked both branches on x86 against the main image with all 156 example solutions. Every test's status and message matches, and the repo's tests pass. The median run is 10.1 s on main, 6.7 s with #331 and 3.9 s with #332. |
dotnet publish builds in Release by default, and the published files are identical without the option. Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| try | ||
| TestRunSuccess(TestResults.parse originalTestCode originalTestTree context) | ||
| with error -> | ||
| // For example, the test executable crashed before writing its results. |
|
Production update: since this was deployed, the median test run has gone from 13.6s to 7.3s (218 runs so far). |
Hello 🙂 I'm working with Claude to try and get our tooling faster.
This PR makes this project around 35% faster, and it's the first of two that together make it around 2.6x faster. I've run it in production to benchmark things in the real world against the most recent few hundred solutions, so I'm confident that it works robustly. However, I've not written the code. I have tried my hardest to get Claude to write sensible messages and comments that explains stuff, but I'd ask for your patience in the fact I'm sending AI code to you. Everything below here is from your friendly neighbourhood LLM...
This is the first of two PRs that speed up the test runner. Merge this one first, then #332.
What changed
Every run spent a large part of its time in
dotnet test.dotnet teststarts MSBuild and the VSTest host, and the VSTest host runs the xUnit v3 test executable. The runner now builds withdotnet buildand runs that executable itself. It passes-trx, so the executable writes the same kind of report as before. If a project doesn't build to a test executable (for example an old xUnit v2 project), the runner still usesdotnet test.The executable escapes quotes, backslashes and control characters in test names and failure messages (it writes
\"for").dotnet testwrote the original text, so the parser now converts the escapes back. Students will see the same names and messages as before.The runner itself is now published with ReadyToRun. It parses the tests with Fantomas.FCS, and the JIT used to compile that parser on every run. The ReadyToRun build needs runtime packs and the ReadyToRun compiler, so the Dockerfile removes them from the package cache before copying it into the runtime image, so they don't stay in the image. The image grows by about 10 MB.
Process.execnow reads the child's output to the end. Before, it redirected the output without reading it. If a child process wrote more output than the pipe can hold, it would block forever.This has been tested in production, and has reduced the median run from 16.4s to 10.7s.
🤖 Generated with Claude Code