Benchmark
swagger-typescript-api-es vs swagger-typescript-api
Both generators run on the same machine, with the same OpenAPI documents and the same options, in separate Node.js processes. The original swagger-typescript-api is the project this library is based on.
Generation · Large spec
23× faster
494 ms vs 11.3 s
Cold run · Large spec
14× faster
938 ms vs 13.1 s
Peak memory · Large spec
2.3× less
251 MB vs 588 MB
Generation time (warm process, median)
lower is better · median of the measured runs after a warm-up run
- swagger-typescript-api-esv0.1.6+8b7c82e
- swagger-typescript-apiv13.13.0
Petstore
OpenAPI 3, 15 schemas, 11 operations (tests/fixtures/petstore.json)
default
9.5× faster
modular
11× faster
Medium
synthetic OpenAPI 3, 300 schemas, 600 operations
default
20× faster
modular
29× faster
extract* + route types
22× faster
Large
synthetic OpenAPI 3, 1500 schemas, 3000 operations
default
23× faster
modular
35× faster
extract* + route types
26× faster
All results
Ratio = time of the original ÷ time of swagger-typescript-api-es. Memory is the peak resident set size of the cold-run process.
| Scenario | Generation (warm, median) | Cold run | Peak memory | Output | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| -es | original | ratio | -es | original | ratio | -es | original | -es | original | |
| Petstore · default | 7.8 ms | 74 ms | 9.5× | 281 ms | 1.02 s | 3.6× | 100 MB | 285 MB | 14 KB | 14 KB |
| Petstore · modular | 7.6 ms | 87 ms | 11× | 279 ms | 1.06 s | 3.8× | 102 MB | 309 MB | 15 KB | 14 KB |
| Medium · default | 107 ms | 2.18 s | 20× | 445 ms | 3.51 s | 7.9× | 145 MB | 386 MB | 327 KB | 316 KB |
| Medium · modular | 96 ms | 2.78 s | 29× | 438 ms | 3.91 s | 8.9× | 149 MB | 363 MB | 485 KB | 306 KB |
| Medium · extract* + route types | 179 ms | 3.92 s | 22× | 562 ms | 5.36 s | 9.5× | 160 MB | 408 MB | 575 KB | 601 KB |
| Large · default | 494 ms | 11.3 s | 23× | 938 ms | 13.1 s | 14× | 251 MB | 588 MB | 1615 KB | 1558 KB |
| Large · modular | 426 ms | 14.9 s | 35× | 880 ms | 16.5 s | 19× | 260 MB | 618 MB | 2414 KB | 1476 KB |
| Large · extract* + route types | 1.03 s | 27.3 s | 26× | 1.90 s | 29.4 s | 15× | 313 MB | 744 MB | 2866 KB | 3005 KB |
How it is measured
- Same input: each run parses the document from JSON and passes it as
spec, withoutput: false(no disk writes) andsilent: true. - Same options for both libraries: default: no options; modular: modular; extract* + route types: extractRequestParams, extractRequestBody, extractResponseBody, extractResponseError, extractEnums, generateRouteTypes.
- Generation: one process per library and scenario, one warm-up generation, then the median of 5 generations.
- Cold run: a new process per run that imports the library and generates once (what a single CLI run costs), median of 3 runs.
- Versions: swagger-typescript-api-es is measured from the repository at commit 8b7c82e (including changes not published to npm yet), the original is the latest npm release, v13.13.0.
- Isolation: every measurement is a separate Node.js process, and the libraries alternate which one runs first.
- Formatting is included, because both generators format their output: swagger-typescript-api-es with oxfmt, the original with Biome (WebAssembly).
Keep in mind
- The medium and large documents are synthetic (objects with enums, arrays,
$refs,oneOfand nullable fields, spread over tags). Real documents have other shapes, so try yours in the playground or run the benchmark with them. - The generated code is similar but not identical (different templates and formatters), which is why the output sizes differ. In modular mode each module file of swagger-typescript-api-es imports every data contract, so its modular output is bigger.
- These numbers come from one machine; absolute times depend on the hardware.
Run it yourself
The benchmark lives in the repository (bench/compare). It installs the original library in its own folder, runs every scenario and writes the results shown on this page.