Benchmarks

Performance comparison: tsz vs tsgo

Benchmarks are run using hyperfine with warmup passes and multiple runs. Each benchmark measures wall-clock time for a full type-check pass (no emit).

tsz is compiled with --profile dist (LTO enabled, single codegen unit). tsgo is the native Go compiler from the TypeScript team.

tsz (Rust) tsgo (Go)
conditionalTypeDiscriminatingLargeUnionRegularTypeFetchingSpeedReasonable.ts
8,012 lines, 136 KB
tsz
104ms
tsgo
443ms tsz 4.3x faster
manyConstExports.ts
5,003 lines, 150 KB
tsz
92ms
tsgo
355ms tsz 3.9x faster
binderBinaryExpressionStress.ts
4,971 lines, 38 KB
tsz
64ms
tsgo
338ms tsz 5.3x faster
binderBinaryExpressionStressJs.ts
4,973 lines, 39 KB
tsz
64ms
tsgo
338ms tsz 5.3x faster
enumLiteralsSubtypeReduction.ts
2,055 lines, 39 KB
tsz
79ms
tsgo
371ms tsz 4.7x faster
binaryArithmeticControlFlowGraphNotTooLarge.ts
1,298 lines, 44 KB
tsz
79ms
tsgo
388ms tsz 4.9x faster
privacyFunctionParameterDeclFile.ts
687 lines, 26 KB
tsz
66ms
tsgo
334ms tsz 5.1x faster
privacyGloFunc.ts
531 lines, 10 KB
tsz
63ms
tsgo
334ms tsz 5.3x faster
privacyTypeParameterOfFunctionDeclFile.ts
440 lines, 14 KB
tsz
62ms
tsgo
332ms tsz 5.3x faster
typedArrays.ts
53 lines, 2 KB
tsz
113ms
tsgo
335ms tsz 3.0x faster
controlFlowArrays.ts
190 lines, 3 KB
tsz
62ms
tsgo
334ms tsz 5.4x faster
utility-types/index.ts
69 lines, 1 KB
tsz
90ms
tsgo
333ms tsz 3.7x faster
utility-types/utility-types.ts
175 lines, 5 KB
tsz
73ms
tsgo
332ms tsz 4.5x faster
utility-types/mapped-types.ts
650 lines, 17 KB
tsz
67ms
tsgo
329ms tsz 4.9x faster
utility-types/aliases-and-guards.ts
103 lines, 3 KB
tsz
57ms
tsgo
331ms tsz 5.8x faster
ts-toolbelt/Iteration/Iteration.ts
215 lines, 8 KB
tsz
61ms
tsgo
330ms tsz 5.4x faster
ts-toolbelt/Misc/BuiltIn.ts
82 lines, 1 KB
tsz
60ms
tsgo
334ms tsz 5.6x faster
ts-toolbelt/Object/Invert.ts
47 lines, 0 KB
tsz
180ms
tsgo
337ms tsz 1.9x faster
ts-toolbelt/Any/Compute.ts
61 lines, 1 KB
tsz
125ms
tsgo
338ms tsz 2.7x faster
ts-essentials/xor.ts
2,717 lines, 44 KB
tsz
106ms
tsgo
337ms tsz 3.2x faster
ts-essentials/paths.ts
101 lines, 3 KB
tsz
187ms
tsgo
333ms tsz 1.8x faster
ts-essentials/deep-pick.ts
47 lines, 1 KB
tsz
94ms
tsgo
338ms tsz 3.6x faster
ts-essentials/deep-readonly.ts
39 lines, 1 KB
tsz
138ms
tsgo
338ms tsz 2.4x faster
10 classes
463 lines, 8 KB
tsz
63ms
tsgo
334ms tsz 5.3x faster
50 classes
2,303 lines, 40 KB
tsz
77ms
tsgo
340ms tsz 4.4x faster
100 classes
4,603 lines, 81 KB
tsz
93ms
tsgo
349ms tsz 3.8x faster
200 classes
9,203 lines, 162 KB
tsz
129ms
tsgo
364ms tsz 2.8x faster
20 generic functions
471 lines, 14 KB
tsz
73ms
tsgo
338ms tsz 4.6x faster
50 generic functions
1,161 lines, 36 KB
tsz
90ms
tsgo
348ms tsz 3.9x faster
100 generic functions
2,311 lines, 72 KB
tsz
119ms
tsgo
365ms tsz 3.1x faster
200 generic functions
4,611 lines, 143 KB
tsz
178ms
tsgo
389ms tsz 2.2x faster
DeepPartial optional-chain N=400
16,424 lines, 4,112 KB
tsz
573ms
tsgo
1699ms tsz 3.0x faster
Shallow optional-chain N=400
16,420 lines, 4,112 KB
tsz
547ms
tsgo
1741ms tsz 3.2x faster
50 union members
131 lines, 6 KB
tsz
66ms
tsgo
335ms tsz 5.1x faster
100 union members
251 lines, 12 KB
tsz
78ms
tsgo
332ms tsz 4.3x faster
200 union members
491 lines, 24 KB
tsz
127ms
tsgo
345ms tsz 2.7x faster
Recursive generic depth=20
39 lines, 1 KB
tsz
61ms
tsgo
340ms tsz 5.6x faster
Recursive generic depth=35
54 lines, 2 KB
tsz
63ms
tsgo
334ms tsz 5.3x faster
Recursive generic depth=45
64 lines, 2 KB
tsz
63ms
tsgo
335ms tsz 5.3x faster
Conditional dist N=50
82 lines, 1 KB
tsz
61ms
tsgo
333ms tsz 5.5x faster
Conditional dist N=80
112 lines, 2 KB
tsz
59ms
tsgo
337ms tsz 5.7x faster
Conditional dist N=95
127 lines, 2 KB
tsz
60ms
tsgo
335ms tsz 5.6x faster
Mapped type keys=100
131 lines, 2 KB
tsz
61ms
tsgo
340ms tsz 5.6x faster
Mapped type keys=300
331 lines, 7 KB
tsz
64ms
tsgo
335ms tsz 5.3x faster
Mapped type keys=450
481 lines, 10 KB
tsz
66ms
tsgo
337ms tsz 5.1x faster
Template literal N=20
83 lines, 1 KB
tsz
59ms
tsgo
343ms tsz 5.8x faster
Template literal N=35
128 lines, 2 KB
tsz
59ms
tsgo
382ms tsz 6.5x faster
Template literal N=45
158 lines, 2 KB
tsz
59ms
tsgo
437ms tsz 7.4x faster
Deep subtype depth=30
81 lines, 2 KB
tsz
62ms
tsgo
340ms tsz 5.5x faster
Deep subtype depth=60
101 lines, 3 KB
tsz
63ms
tsgo
350ms tsz 5.6x faster
Deep subtype depth=90
101 lines, 3 KB
tsz
63ms
tsgo
347ms tsz 5.5x faster
Intersection N=20
139 lines, 2 KB
tsz
60ms
tsgo
331ms tsz 5.5x faster
Intersection N=35
229 lines, 3 KB
tsz
61ms
tsgo
336ms tsz 5.5x faster
Intersection N=45
289 lines, 4 KB
tsz
61ms
tsgo
335ms tsz 5.5x faster
Infer stress N=15
249 lines, 5 KB
tsz
60ms
tsgo
337ms tsz 5.6x faster
Infer stress N=25
514 lines, 10 KB
tsz
62ms
tsgo
332ms tsz 5.4x faster
Infer stress N=30
684 lines, 13 KB
tsz
62ms
tsgo
339ms tsz 5.4x faster
CFA branches=50
313 lines, 9 KB
tsz
77ms
tsgo
349ms tsz 4.5x faster
CFA branches=100
603 lines, 18 KB
tsz
123ms
tsgo
471ms tsz 3.8x faster
CFA branches=150
893 lines, 27 KB
tsz
200ms
tsgo
776ms tsz 3.9x faster
BCT candidates=25
78 lines, 5 KB
tsz
64ms
tsgo
338ms tsz 5.3x faster
BCT candidates=50
128 lines, 9 KB
tsz
69ms
tsgo
339ms tsz 4.9x faster
BCT candidates=100
228 lines, 17 KB
tsz
87ms
tsgo
351ms tsz 4.0x faster
BCT candidates=200
428 lines, 36 KB
tsz
148ms
tsgo
384ms tsz 2.6x faster
Constraint conflicts N=20
99 lines, 7 KB
tsz
61ms
tsgo
337ms tsz 5.5x faster
Constraint conflicts N=50
219 lines, 28 KB
tsz
66ms
tsgo
339ms tsz 5.1x faster
Constraint conflicts N=100
419 lines, 89 KB
tsz
77ms
tsgo
357ms tsz 4.7x faster
Constraint conflicts N=200
819 lines, 321 KB
tsz
113ms
tsgo
406ms tsz 3.6x faster
Mapped complex template keys=25
77 lines, 3 KB
tsz
62ms
tsgo
332ms tsz 5.4x faster
Mapped complex template keys=50
102 lines, 3 KB
tsz
62ms
tsgo
335ms tsz 5.4x faster
Mapped complex template keys=100
152 lines, 5 KB
tsz
64ms
tsgo
335ms tsz 5.2x faster
Mapped complex template keys=200
252 lines, 7 KB
tsz
69ms
tsgo
339ms tsz 4.9x faster

Running Benchmarks Locally

To generate benchmark data yourself:

./scripts/bench-vs-tsgo.sh --json

This produces a JSON file in artifacts/ that the website build script uses to generate charts. Use --quick for faster results with fewer iterations.

See bench-vs-tsgo.sh for full usage.