Skip to content

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.

All benchmark results
ScenarioGeneration (warm, median)Cold runPeak memoryOutput
-esoriginalratio-esoriginalratio-esoriginal-esoriginal
Petstore · default7.8 ms74 ms9.5×281 ms1.02 s3.6×100 MB285 MB14 KB14 KB
Petstore · modular7.6 ms87 ms11×279 ms1.06 s3.8×102 MB309 MB15 KB14 KB
Medium · default107 ms2.18 s20×445 ms3.51 s7.9×145 MB386 MB327 KB316 KB
Medium · modular96 ms2.78 s29×438 ms3.91 s8.9×149 MB363 MB485 KB306 KB
Medium · extract* + route types179 ms3.92 s22×562 ms5.36 s9.5×160 MB408 MB575 KB601 KB
Large · default494 ms11.3 s23×938 ms13.1 s14×251 MB588 MB1615 KB1558 KB
Large · modular426 ms14.9 s35×880 ms16.5 s19×260 MB618 MB2414 KB1476 KB
Large · extract* + route types1.03 s27.3 s26×1.90 s29.4 s15×313 MB744 MB2866 KB3005 KB

How it is measured

  • Same input: each run parses the document from JSON and passes it as spec, with output: false (no disk writes) and silent: 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, oneOf and 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.

terminal
git clone https://github.com/hunghg255/swagger-typescript-api-es
cd swagger-typescript-api-es
npm install
npm run bench:compare
# options: -- --runs 10 --cold-runs 5 --filter large
Read the docs