Performance
This page describes what we measure on @cosyte/dicom, how we measure it, and how to run the
benchmarks yourself. The shared method every Cosyte package follows (throughput, latency
percentiles, memory, import time and bundle size, and how a pull request is compared with main)
is written down in the performance standard in
cosyte/config, the repository our shared configuration lives in.
The numbers for the current release are in Current numbers below.
Three things run today: the benchmarks, which compare a pull request's build with its base; the scaling gates, which fail a pull request when parsing, reading or writing grows faster than its input; and a reading with a memory profile on a GitHub-hosted runner when the benchmarks change.
What a parse costs depends on what you read. parseDicom decodes an element's value the first time
something reads it, and keeps Pixel Data as raw bytes that are never decoded. To index large files,
readDicomHeader reads only as far as the Pixel Data; Recipes
shows it.
The benchmarks
bench/dicom.bench.mjs is our benchmark suite, run by the shared @cosyte/bench tool against the
built dist/index.mjs, the entry a consumer imports. It measures synthetic files in the shapes real
traffic has, each built in code by bench/shapes.mjs:
- a Modality Worklist entry, the small object a modality reads all day;
- a CT slice of 512 by 512 pixels at 16 bits;
- an Enhanced CT series of many frames, at two sizes;
- a header-only structured report of many small tags in Sequences nested four deep.
Each shape is parsed, parsed then read tag by tag, and written. A reading reports throughput,
latency at p50, p95 and p99, allocations, peak heap, a long run for leaks, and the cold import with
its gzip size. The peak heap is the V8 heap only, so Pixel Data, which is a Buffer, is not in it:
bench/profile.mjs measures each large size's peak resident memory and single-call time in a fresh
process, then profiles the hottest paths. bench/budgets.mjs judges each shape's peak memory
against a budget.
test/perf/bench-shapes.test.ts holds that every shape reads cleanly and writes back to its own
bytes, so the benchmarks measure correct work.
In CI
- On every pull request, CI builds the base and the head and compares them at each shape's first size. The comparison is advisory: it reports, it does not fail.
- The scaling gates (
test/perf/scaling-gate.perf.ts) run in their own job on every pull request and fail whenparseDicom, reading every tag orserializeDicomgrows faster than its input. - When
bench/changes,.github/workflows/bench.ymltakes a full reading and a profile on a GitHub-hosted runner, one job per shape, and keeps the results as artifacts. It is advisory too.
Run them yourself
pnpm install --frozen-lockfile
pnpm build
pnpm bench:reading --out bench-results/reading.json --summary bench-results/reading.md
node bench/budgets.mjs bench-results/reading.json
pnpm bench:compare --base <base checkout>/dist/index.mjs --head dist/index.mjs
pnpm bench:profile --out bench-results/profile
pnpm test:perf
A reading names the machine it ran on. Compare readings from the same machine only.
Current numbers
Measured for version 0.1.18 at commit 375f8c6 on 2026-11-29, in the release run that published it. Each reading below was taken in that run by @cosyte/bench (cosyte-bench run) against the built entry, in fresh Node.js processes, after the scaling gate (pnpm test:perf) passed. A reading is one run on one machine, not a bound.
@cosyte/dicom
bench/dicom.bench.mjs against dist/index.mjs, by @cosyte/bench 0.1.5 on 2026-11-29: 3 fresh processes for each case, on a GitHub-hosted runner (github-actions-github-hosted-ubuntu26-x64, image ubuntu26 20261122.9.1), AMD EPYC 7763 64-Core Processor with 4 logical CPUs, Node.js v22.23.5.
| Benchmark | Size | Input | Per call | Throughput | p50 | p95 | p99 | Allocated per call | Peak heap |
|---|---|---|---|---|---|---|---|---|---|
| parseDicom: worklist item | 1 KiB | 1.0 KiB | 11.57 us | 88.16 MiB/s | 10.67 us | 20.58 us | 38.99 us | 7.9 KiB | 23.0 KiB |
| parseDicom, then read tags: worklist item | 1 KiB | 1.0 KiB | 34.72 us | 29.39 MiB/s | 33.41 us | 47.43 us | 81.51 us | 22.1 KiB | 47.0 KiB |
| serializeDicom: worklist item | 1 KiB | 1.0 KiB | 10.79 us | 94.57 MiB/s | 11.12 us | 13.98 us | 24.59 us | 9.3 KiB | 21.1 KiB |
| parseDicom: CT | single frame, 514 KiB | 513.6 KiB | 24.49 us | 20479.76 MiB/s | 19.68 us | 31.78 us | 56.23 us | 7.8 KiB | 22.9 KiB |
| parseDicom: CT | 20 frames, 10 MiB | 10.00 MiB | 80.58 us | 124160.68 MiB/s | 75.36 us | 128.92 us | 209.37 us | 54.5 KiB | 93.9 KiB |
| parseDicom: CT | 200 frames, 100 MiB | 100.04 MiB | 625.61 us | 159906.63 MiB/s | 569.90 us | 720.79 us | 815.87 us | 458.4 KiB | 524.3 KiB |
| parseDicom, then read tags: CT | single frame, 514 KiB | 513.6 KiB | 72.75 us | 6895.26 MiB/s | 67.20 us | 84.64 us | 198.49 us | 40.5 KiB | 72.1 KiB |
| parseDicom, then read tags: CT | 20 frames, 10 MiB | 10.00 MiB | 243.09 us | 41156.47 MiB/s | 211.04 us | 256.86 us | 446.00 us | 180.5 KiB | 271.0 KiB |
| parseDicom, then read tags: CT | 200 frames, 100 MiB | 100.04 MiB | 1.834 ms | 54536.77 MiB/s | 1.700 ms | 2.357 ms | 2.687 ms | 1.50 MiB | 1.91 MiB |
| serializeDicom: CT | single frame, 514 KiB | 513.6 KiB | 65.18 us | 7695.17 MiB/s | 64.02 us | 76.30 us | 197.17 us | 15.5 KiB | 27.6 KiB |
| serializeDicom: CT | 20 frames, 10 MiB | 10.00 MiB | 1.941 ms | 5154.70 MiB/s | 1.004 ms | 5.243 ms | 5.502 ms | 63.5 KiB | 94.3 KiB |
| serializeDicom: CT | 200 frames, 100 MiB | 100.04 MiB | 66.536 ms | 1503.55 MiB/s | 66.727 ms | not measured: too few calls | not measured: too few calls | 586.4 KiB | 564.4 KiB |
| parseDicom: SR, header only | 50 measurements, 26 KiB | 26.0 KiB | 298.72 us | 84.88 MiB/s | 291.66 us | 397.75 us | 502.06 us | 108.7 KiB | 424.0 KiB |
| parseDicom: SR, header only | 1,000 measurements, 503 KiB | 503.5 KiB | 5.115 ms | 96.13 MiB/s | 4.918 ms | 5.378 ms | not measured: too few calls | 1.85 MiB | 3.47 MiB |
| parseDicom: SR, header only | 10,000 measurements, 4.9 MiB | 4.91 MiB | 50.956 ms | 96.33 MiB/s | 48.475 ms | not measured: too few calls | not measured: too few calls | 18.95 MiB | 15.82 MiB |
| parseDicom, then read tags: SR, header only | 50 measurements, 26 KiB | 26.0 KiB | 828.11 us | 30.62 MiB/s | 797.94 us | 969.75 us | 1.264 ms | 589.5 KiB | 1.07 MiB |
| parseDicom, then read tags: SR, header only | 1,000 measurements, 503 KiB | 503.5 KiB | 17.054 ms | 28.83 MiB/s | 16.383 ms | not measured: too few calls | not measured: too few calls | 10.70 MiB | 14.27 MiB |
| parseDicom, then read tags: SR, header only | 10,000 measurements, 4.9 MiB | 4.91 MiB | 224.752 ms | 21.84 MiB/s | 223.164 ms | not measured: too few calls | not measured: too few calls | 112.00 MiB | 76.03 MiB |
| serializeDicom: SR, header only | 50 measurements, 26 KiB | 26.0 KiB | 249.75 us | 101.52 MiB/s | 237.30 us | 336.45 us | 377.94 us | 303.5 KiB | 315.2 KiB |
| serializeDicom: SR, header only | 1,000 measurements, 503 KiB | 503.5 KiB | 5.567 ms | 88.32 MiB/s | 5.344 ms | 6.391 ms | not measured: too few calls | 5.77 MiB | 5.80 MiB |
| serializeDicom: SR, header only | 10,000 measurements, 4.9 MiB | 4.91 MiB | 59.402 ms | 82.63 MiB/s | 58.585 ms | not measured: too few calls | not measured: too few calls | 57.64 MiB | 15.74 MiB |
Cold import of dist/index.mjs: a median of 15.915 ms, 15.383 ms above an empty module, loading 1 files of 823.0 KiB (180.6 KiB gzipped).