Go vs transpiled C# — runtime performance comparison

Measured on: the results below were measured on G-LAPTOP, an AMD Ryzen 5 PRO 6650U running Windows 11. The C# columns are Windows x64 (win-x64): each program is converted by go2cs from Go 1.26.10 and references the published go.* 1.26.10.2 packages from nuget.org, and it runs on .NET 10 (SDK 10.0.400, runtime 10.0.11). The Go column is the same programs built by Go 1.26.10 for windows/amd64. The win-x64 Native AOT images were compiled on a second machine (SDK 10.0.403, ILC 10.0.14) and timed on G-LAPTOP. The tables under History were measured on the same win-x64 machine, and each names its own toolchain.

A small, targeted benchmark suite answering the question people ask first: how fast is transpiled C# compared to the original Go? — startup time and run time, under the normal JIT runtime, a ReadyToRun publish (what dotnet publish of a converted program gives you), and Native AOT (self-contained, the closest deployment analog to a Go binary).

Each benchmark is a tiny Go program (same shape as the behavioral tests), chosen to exercise one Go construct with a real C# cost model — slices, strings, maps, channels, interface dispatch — plus raw compute loops where the two runtimes should be close. This is not an exhaustive benchmark game; it gives the common expected range of differences. The short version: transpiled C# is usually slower than Go, but not universally — maps run faster than Go in every C# column, and so do recursive function calls (Fib) under the JIT and ReadyToRun, while the rest ranges from about 2× on tight compute under the JIT to the duck-typed interface asserts and the boxed field addresses, the honest outliers at the other end.

To choose a deployment and runtime settings for your own program, see Tuning converted code: it explains which knobs exist, what each trades, and why the suite’s diagnostic runs with tiering off are not advice. The suite itself is not tuned: each program is converted with go2cs’s default settings and built from the project file the converter writes, the way a user would. The fairness notes say exactly what that covers.

The benchmarks

Benchmark What it exercises
Startup Empty workload: pure process start + runtime init + one fmt round-trip. Wall time.
Fib Recursive Fibonacci (fib(34) ×5): function-call and integer-op overhead.
Sieve Sieve of Eratosthenes to 10M ×3: slice allocation, indexing, tight loops (slice<T> bounds/header emulation).
MatMul 256×256 float64 matrix multiply ×4: floating-point throughput, nested slice-of-slice access.
String 10M iterations of byte-slice append → string conversion, indexing, concatenation (@string emulation).
StringView 20M iterations of keyword checks string(buf) == "null"/"true"/"false" over a fixed buffer — the idiom the converter’s stack-string (sstring) emission optimizes: a zero-copy view compared against a u8 literal span, no per-comparison allocation.
StringMatch 20M iterations of literal-string hot paths: switch-on-string dispatch, strings.HasPrefix with a literal prefix, literal returns, literal map-key counters — the shapes where a naive conversion would allocate a fresh @string per evaluation while Go allocates nothing (string literals live in RODATA). Instrument for the literal-comparison optimizations (span operators, u8 casts, hoisted literals).
Map 2M inserts + 2M comma-ok lookups + 1M deletes on map[int]int (map<K,V> emulation).
Sort sort.Ints on 2M deterministic pseudo-random ints (sort.Interface dispatch through the runtime’s reflection-bound Interface<T>).
Channel 1M ints producer→consumer through a buffered channel with one goroutine (channel<T> + goroutine scheduling emulation).
IfaceCall 50M iterations of pure interface method dispatch — interface values of statically-known types built once, called in a megamorphic hot loop; no asserts, no switches. The row that answers “what does calling an interface method cost?”
Iface 20M iterations of the common interface cases: method dispatch, concrete comma-ok assertions, and a type switch over a closed set — all resolved by the compile-time (nominal) machinery: generated adapters and cast-shaped asserts. What ordinary Go interface code costs.
IfaceShell 5M iterations × 2 duck-typed interface asserts + forwarded calls — one on a value-typed dynamic value (the reflective object shell), one on a pointer-sourced one (the delegate-bound generic shell). The one path with no compile-time answer, and the only shared mechanism whose Native AOT behavior is otherwise unexercised.
IfaceShellChurn 1M iterations of the same duck-typed asserts as IfaceShell, but every assert sees a NEW dynamic value (a fresh struct, a fresh pointer, and errors.Is over a fresh *fs.PathError). IfaceShell is the case a shell cache wins on; this is the case it can only lose on, so the pair bounds what a cache costs. run-shell-churn-bound.ps1 holds that cost to 1.15x time and 1.25x peak working set against the same row built with the cache compiled out.
RefLower A pointer-heavy hot loop: pointer parameters passed on to pointer parameters, address-taken locals and field addresses — the shapes the converter’s ref-lowering turns from heap boxes into native C# refs.
FieldView Field addresses that stay boxed: methods on *element taking *element operands and returning the receiver (crypto/internal/fiat’s P-256 shape), every operand an &p.f and its own call site, over a pointer and over &pts[i]. Measures the field-view cache (golib ж.Views.cs) matching each site to its field’s one view, on a pointer’s box and on fresh element boxes.
TlsHandshake 64 full TLS 1.3 handshakes over loopback, one fresh connection each, after one warm-up handshake; the certificate is parsed before the clock starts. Isolates the handshake latency that net/http’s h2 write-deadline tests bound only indirectly.

Every benchmark prints a deterministic checksum (verified byte-identical across Go, C# JIT, and C# AOT before anything is measured) plus its own workload time measured in-program via time.Now().UnixNano() — so the headline numbers exclude process startup, which is reported separately by the Startup row.

Methodology / fairness notes

Running it

cd src/tests/Performance
./run-performance.ps1                    # full run: transpile, build (incl. AOT), verify, measure
./run-performance.ps1 --no-aot           # skip AOT publishes, faster while iterating
./run-performance.ps1 --filter Map       # one benchmark
./run-performance.ps1 --runs 10 --update-readme   # refresh the results block below

Requirements: the Go release go2cs converts (Go 1.26.11, the <GoStdLibVersion> in src/version.props), a .NET SDK matching the corpus target framework (net10.0, named by src/Directory.Build.props), and — for the AOT column — a native linker and toolchain, which differs by host:

Host Native AOT prerequisite
Windows MSVC C++ build tools — Visual Studio 2022’s “Desktop development with C++” workload, which supplies the link.exe ILC needs. The runner prepends the VS Installer directory to PATH so the SDK’s vswhere probe finds it.
Linux clang and zlib1g-dev (Debian/Ubuntu: sudo apt install clang zlib1g-dev; Fedora: clang zlib-devel). ILC shells out to clang for the native link step.
macOS The Xcode command line tools (xcode-select --install), which supply clang and ld.

Deliberately not scripted: run-performance.ps1 does not install any of these. A benchmark harness that silently mutates the machine’s toolchain is not a harness anyone should trust with a performance claim. --no-aot drops the whole column and needs none of them.

The environment line of the results block reads the CPU name from the registry on Windows and from /proc/cpuinfo on Linux, so a published table always names the part that produced it.

The runner (PerformanceRunner), a dependency-free console app structured like the behavioral suite’s BehavioralRunner, runs Transpile → Build → Verify → Measure. Verify requires all three binaries to produce identical (timing-filtered) stdout before anything is timed, so the table can never silently report a benchmark that computes something different in C#.

Results

The table below has the 17 programs the suite held when it was measured (PerfDeferPanic joined after), measured against the published go.* 1.26.10.2 packages. The same programs measured in the same session against go.* 1.24.13.7 are under History, with the older tables.

Environment: AMD Ryzen 5 PRO 6650U with Radeon Graphics (G-LAPTOP) · Microsoft Windows 10.0.26300 · go1.26.10 · .NET SDK 10.0.400, runtime 10.0.11 · go.* 1.26.10.2 · 2026-11-04/05

Columns, one RID and shape each:

Median of 5 runs (11 for Startup, Sort, Channel, IfaceCall, Iface and RefLower, and for FieldView under Native AOT), 1 discarded warmup. Workload time is measured in-program and excludes process startup; the Startup row is pure process wall time. Ratios are relative to Go: the JIT and ReadyToRun ratios to the Go column, timed in the same window, and the Native AOT ratio to the same Go binaries timed again in the Native AOT window.

Execution time (milliseconds – lower is better):

Benchmark Go C# (JIT) C# (ReadyToRun) C# (Native AOT)
Startup 26.1 506.4 (19.40×) 371.4 (14.23×) 158.8 (6.40×)
Fib 115.1 96.9 (0.84×) 101.3 (0.88×) 177.5 (1.52×)
Sieve 62.8 134.0 (2.13×) 135.7 (2.16×) 295.0 (5.13×)
MatMul 123.0 217.0 (1.76×) 215.7 (1.75×) 726.8 (6.17×)
String 103.8 340.1 (3.28×) 655.7 (6.32×) 1,396.5 (13.24×)
StringView 9.6 21.9 (2.28×) 21.7 (2.26×) 19.2 (1.85×)
StringMatch 174.7 776.2 (4.44×) 789.2 (4.52×) 1,274.4 (7.33×)
Map 661.7 251.0 (0.38×) 252.0 (0.38×) 285.6 (0.44×)
Sort 140.1 252.5 (1.80×) 252.4 (1.80×) 543.6 (4.00×)
Channel 39.8 78.5 (1.97×) 83.7 (2.10×) 103.6 (2.58×)
IfaceCall 184.4 336.2 (1.82×) 345.2 (1.87×) 559.6 (3.12×)
Iface 90.4 375.3 (4.15×) 376.6 (4.17×) 572.8 (6.80×)
IfaceShell 22.3 602.7 (27.03×) 581.9 (26.09×) 1,177.5 (52.75×)
IfaceShellChurn 36.9 1,083.4 (29.36×) 1,073.1 (29.08×) 1,712.0 (46.93×)
FieldView 41.7 1,725.3 (41.37×) 1,911.4 (45.84×) 2,347.1 (57.76×)
RefLower 240.6 510.2 (2.12×) 536.3 (2.23×) 644.5 (2.69×)
TlsHandshake 128.2 1,057.9 (8.25×) 1,078.7 (8.41×) 2,534.2 (20.41×)

Notes on this table:

Reading the results

What the AOT column costs to produce — the honesty footnote

The table above shows what a Native AOT binary does at run time. It does not show what that binary costs to build, and the cost is large enough that omitting it would mislead:

History

Prior tables live here so cross-release and cross-toolchain comparisons stay honest: same benchmarks, same methodology, same host. Each table names its toolchain and says what else differed from the current one.

go.* 1.24.13.7, measured in the same session

The same 17 programs, each converted by the go2cs release that shipped go.* 1.24.13.7 and referencing those packages from nuget.org, timed in the same session and on the same win-x64 machine as the current table, the two releases alternating run by run. Milliseconds, median, with the current table’s run counts; compare each cell with the current table’s C# column of the same name.

Benchmark C# (JIT) C# (ReadyToRun) C# (Native AOT, folding off)
Startup 607.8 333.6 580.6
Fib 181.8 179.6 178.9
Sieve 135.2 343.4 320.6
MatMul 214.3 634.5 732.1
String 732.8 1,621.8 1,394.2
StringView 18.9 645.6 24.1
StringMatch 896.0 1,469.5 1,154.8
Map 455.7 659.5 307.0
Sort 429.1 361.7 542.6
Channel 108.7 162.9 116.9
IfaceCall 388.2 1,510.7 520.1
Iface 533.8 844.8 564.3
IfaceShell 936.3 991.6 1,505.0
IfaceShellChurn 1,531.0 1,229.9 1,533.3
FieldView 9,449.3 6,341.7 6,055.6
RefLower 636.8 660.0 1,875.5
TlsHandshake 2,405.6 1,680.2 n/a (LNK1183)

How this table differs from the current one:

Native AOT build cost before golib’s generic-cycle fix

Before golib’s generic-cycle fix of 2026-10-14, a Native AOT publish of one benchmark for win-x64 took hours. On 2026-08-24, with Go 1.23.1 and .NET 10, one publish took 11,862 s (about 3.3 hours) on the machine that timed the tables, about ten times the 894 to 953 s the .NET 9 compiler took on the same input. The compiler’s peak working set read 14.9 GB on that machine, and 17.7 GB and 22.2 GB on the second, Windows machine on 2026-08-25 and 2026-10-13.

Go 1.23.1, .NET 10 (SDK 10.0.400) — 2026-08-25

Environment: AMD Ryzen 5 PRO 6650U with Radeon Graphics · Microsoft Windows 10.0.26200 · go1.23.1 · .NET SDK 10.0.400 · 2026-08-25

C# builds: JIT = framework-dependent Release; Native AOT = -p:PublishAot=true self-contained, partial trim. Median of 5 runs (1 discarded warmup). Workload time is measured in-program and excludes process startup; the Startup row is pure process wall time. Ratios are relative to Go.

Execution time (milliseconds – lower is better):

Benchmark Go C# (JIT) C# (Native AOT)
Startup 22.9 279.4 (12.20×) 36.7 (1.60×)
Fib 120.4 163.7 (1.36×) 178.0 (1.48×)
Sieve 68.5 126.1 (1.84×) 242.4 (3.54×)
MatMul 107.3 216.3 (2.02×) 594.9 (5.55×)
String 103.6 701.7 (6.78×) 1,272.5 (12.29×)
StringView 19.3 19.5 (1.01×) 22.0 (1.14×)
StringMatch 199.2 935.7 (4.70×) 1,156.7 (5.81×)
Map 631.2 422.3 (0.67×) 248.8 (0.39×)
Sort 141.3 405.9 (2.87×) 473.5 (3.35×)
Channel 39.4 92.2 (2.34×) 113.3 (2.87×)
IfaceCall 182.2 398.1 (2.19×) 439.2 (2.41×)
Iface 94.8 557.4 (5.88×) 476.8 (5.03×)
IfaceShell 21.7 757.0 (34.88×) 1,255.2 (57.84×)
RefLower 234.4 643.8 (2.75×) 1,852.3 (7.90×)

Peak memory (working set, MB – lower is better):

Benchmark Go C# (JIT) C# (Native AOT)
Startup 4.3 47.4 12.5
Fib 5.7 48.5 14.1
Sieve 26.4 67.3 33.8
MatMul 11.0 54.4 20.4
String 5.7 57.2 23.0
StringView 5.7 48.7 14.1
StringMatch 5.7 57.2 22.9
Map 158.8 164.2 130.4
Sort 21.9 64.7 29.4
Channel 5.7 53.4 19.3
IfaceCall 5.7 48.0 14.1
Iface 5.7 48.4 14.4
IfaceShell 5.7 68.4 35.7
RefLower 5.8 48.3 15.3

How this table differs from the current one:

Compile provenance of the Go 1.23.1 table

The Native AOT column above is mixed-provenance, deliberately and under a measured licence. A single Native AOT publish of this corpus costs ~3.3 h on the measurement host, so the fourteen-cell AOT ladder was completed by publishing eight of the binaries on a second, higher-memory machine and adopting them here, each SHA-256-verified on receipt:

provenance rows
canon — published on the measurement host itself Startup, Fib, Sieve, MatMul, String, RefLower
farm-adopted — published on the second machine, hash-verified, then measured here StringView, StringMatch, Map, Sort, Channel, IfaceCall, Iface, IfaceShell

Every row, whatever its provenance, was measured on the canon host only, and every adopted binary passed the suite’s own Verify phase (output-identical to Go) before it was timed. The adoption is licensed by a direct A/B rather than by assumption: one benchmark published on both machines measured 0.25 % apart, against a 1.19 % empirical null established by two known-equivalent binaries from the same host — that is, the cross-machine difference is smaller than the host’s own run-to-run spread. The raw data, including all four binary hashes, is kept with the project’s measurement records.

.NET 9 (SDK 9.0.316) — 2026-08-24

Environment: AMD Ryzen 5 PRO 6650U with Radeon Graphics · Microsoft Windows 10.0.26200 · go1.23.1 · .NET SDK 9.0.316 · 2026-08-24

Execution time (milliseconds – lower is better):

Benchmark Go C# (JIT) C# (Native AOT)
Startup 25.8 245.3 (9.52×) 79.2 (3.07×)
Fib 119.8 180.3 (1.51×) 175.3 (1.46×)
Sieve 71.7 128.3 (1.79×) 265.4 (3.70×)
MatMul 105.6 209.3 (1.98×) 598.5 (5.67×)
String 104.6 1,208.3 (11.56×) 1,600.3 (15.31×)
StringView 19.5 21.7 (1.12×) 18.9 (0.97×)
StringMatch 198.6 992.8 (5.00×) 1,279.8 (6.44×)
Map 630.5 546.4 (0.87×) 230.7 (0.37×)
Sort 135.0 461.4 (3.42×) 497.8 (3.69×)
Channel 46.6 96.0 (2.06×) 130.9 (2.81×)
IfaceCall 181.8 395.8 (2.18×) 427.2 (2.35×)
Iface 96.5 538.7 (5.58×) 462.7 (4.80×)
IfaceShell 21.3 871.9 (40.90×) 1,319.0 (61.87×)
RefLower 239.1 624.7 (2.61×) 1,890.7 (7.91×)

Peak memory (working set, MB – lower is better):

Benchmark Go C# (JIT) C# (Native AOT)
Startup 2.5 46.1 76.9
Fib 5.3 46.1 75.8
Sieve 25.9 65.6 96.6
MatMul 10.6 53.4 83.4
String 5.2 55.8 85.7
StringView 5.3 46.8 77.1
StringMatch 5.3 56.1 87.0
Map 157.9 165.8 187.1
Sort 21.4 62.4 92.2
Channel 5.3 52.0 84.3
IfaceCall 5.3 46.3 77.4
Iface 5.3 46.6 77.4
IfaceShell 5.3 66.6 96.3
RefLower 5.3 46.9 77.1

What the move to .NET 10 changed. Two results dominate, and they are why this table is kept:

Elsewhere the move is mostly favourable and often within the noise band. The largest single JIT gain is String (11.56× to 6.78× Go), with StringMatch (5.00× to 4.70×) and IfaceShell (40.90× to 34.88×) following it down; the AOT column’s time cells are broadly flat outside Startup.

Performance-floor exploration

A floor exploration on win-x64 in August 2026 compared stock-SDK trim profiles with bflat and found that the Native AOT image-size floor is set by which assemblies the trim roots whole, not by the toolchain. run-performance-floor.ps1 is its measurement harness and is not part of the canonical suite above.