|
| 1 | +# Performance Analysis (detailed) |
| 2 | + |
| 3 | +This document contains the full performance measurements for reference. The main `readme.md` only highlights the key "unchanged re-run" numbers. |
| 4 | + |
| 5 | +## Approaches |
| 6 | + |
| 7 | +- `go app.cs` — invoked via the RID-specific published binary (never `dotnet run` on the tool project) |
| 8 | +- `dotnet run app.cs` — built-in file-based run (no AOT) |
| 9 | +- `dotnet publish app.cs /p:PublishAot=... ; artifacts/app/app.exe` |
| 10 | + |
| 11 | +## Examples |
| 12 | + |
| 13 | +Four minimal, package-free examples live under `samples/`: |
| 14 | + |
| 15 | +- **a) no includes** — `samples/noinc/app.cs` |
| 16 | +- **b) #include** — `samples/include/{app.cs, lib.cs}` |
| 17 | +- **c) #ref** — `samples/ref/{app.cs, lib.cs}` |
| 18 | +- **d) #include + #ref** — `samples/incref/{app.cs, inclib.cs, reflib.cs}` |
| 19 | + |
| 20 | +All declare `TargetFramework=net10.0` (plus the Experimental flag for #ref cases). |
| 21 | + |
| 22 | +## Methodology |
| 23 | + |
| 24 | +- Environment: Windows + .NET 11.0.100-preview.5 SDK. |
| 25 | +- All timings via `pwsh` `Measure-Command`. |
| 26 | +- `go` binary: always the RID-specific published exe (win-x64, --no-self-contained). |
| 27 | +- AOT control via `/p:PublishAot=false|true`. |
| 28 | +- Scenarios captured: |
| 29 | + - first-run (clean state) |
| 30 | + - unchanged re-runs (pristine sources) |
| 31 | + - run/edit/run |
| 32 | +- Raw data is in the goal scratch directory (`perf-logs/`). |
| 33 | + |
| 34 | +The tool provides fast re-runs for unchanged sources through its build caching. |
| 35 | + |
| 36 | +## Unchanged re-runs (pristine sources – last observed) |
| 37 | + |
| 38 | +**PublishAot=false** |
| 39 | + |
| 40 | +| Example | `dotnet run app.cs` | `go app.cs` (RID exe) | `dotnet publish ... ; app.exe` | |
| 41 | +|--------------------|---------------------|-----------------------|--------------------------------| |
| 42 | +| a) no includes | 1.306s | 0.264s | 5.044s | |
| 43 | +| b) #include | 1.169s | 0.198s | 4.857s | |
| 44 | +| c) #ref | 4.605s | 0.191s | 6.243s | |
| 45 | +| d) #include + #ref | 13.079s | 0.227s | 7.320s | |
| 46 | + |
| 47 | +**PublishAot=true** (NativeAOT) |
| 48 | + |
| 49 | +| Example | `dotnet run app.cs` | `go app.cs` (RID exe) | `dotnet publish ... ; app.exe` | |
| 50 | +|--------------------|---------------------|-----------------------|--------------------------------| |
| 51 | +| a) no includes | — | 0.227s | 12.436s | |
| 52 | +| b) #include | — | 0.164s | 11.145s | |
| 53 | +| c) #ref | — | 0.183s | 32.874s | |
| 54 | +| d) #include + #ref | — | 0.269s | 21.888s | |
| 55 | + |
| 56 | +**Observation**: `go` re-runs (both AOT modes) are now ~0.16–0.27s — just launching the already-published executable. |
| 57 | + |
| 58 | +## First-run (clean state) |
| 59 | + |
| 60 | +AOT=true first runs are significantly slower due to NativeAOT compilation. |
| 61 | + |
| 62 | +| Example | `dotnet run` | `go` (AOT=false) | `publish` (AOT=false) | `go` (AOT=true) | `publish` (AOT=true) | |
| 63 | +|---------|--------------|------------------|-----------------------|-----------------|----------------------| |
| 64 | +| a) noinc | 6–12s | ~20s | ~8–13s | ~20s | ~17–23s | |
| 65 | +| b) include | ~5–11s | ~20s | ~7s | ~18s | ~20s | |
| 66 | +| c) ref | ~6–7s | ~19s | ~8s | ~20s | ~18s | |
| 67 | +| d) incref | ~11s | ~38s | ~7.5s | ~32s | ~27s | |
| 68 | + |
| 69 | +## run / edit / run |
| 70 | + |
| 71 | +After editing the source, the next invocation was measured (with prior artifacts left in place). |
| 72 | + |
| 73 | +See the raw logs for exact per-cell values. The important takeaway is that once a native AOT executable has been produced by `go`, launching it remains extremely fast even after source changes (until a rebuild is triggered). |
| 74 | + |
| 75 | +## Full raw data |
| 76 | + |
| 77 | +All `Measure-Command` output and per-run summaries live in the private scratch directory used during measurement (typically under the goal session temp folder). |
| 78 | + |
| 79 | +Example commands used: |
| 80 | + |
| 81 | +```pwsh |
| 82 | +& '...\go-tool-rid\go.exe' app.cs -- /p:PublishAot=false |
| 83 | +& '...\go-tool-rid\go.exe' app.cs -- /p:PublishAot=true |
| 84 | +``` |
| 85 | + |
| 86 | +--- |
| 87 | + |
| 88 | +*This file is for future reference. The primary user-facing numbers are in the root `readme.md`.* |
0 commit comments