Skip to main content
Version: v0.2.0

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 when parseDicom, reading every tag or serializeDicom grows faster than its input.
  • When bench/ changes, .github/workflows/bench.yml takes 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.2.0 at commit 9f078f2 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 9V74 80-Core Processor with 4 logical CPUs, Node.js v22.23.5.

BenchmarkSizeInputPer callThroughputp50p95p99Allocated per callPeak heap
parseDicom: worklist item1 KiB1.0 KiB9.21 us110.78 MiB/s8.64 us13.44 us22.36 us8.5 KiB23.6 KiB
parseDicom, then read tags: worklist item1 KiB1.0 KiB36.66 us27.84 MiB/s35.22 us43.66 us70.86 us30.3 KiB58.6 KiB
serializeDicom: worklist item1 KiB1.0 KiB7.28 us140.18 MiB/s7.09 us8.29 us15.73 us6.2 KiB17.5 KiB
parseDicom: CTsingle frame, 514 KiB513.6 KiB15.79 us31774.87 MiB/s14.87 us24.06 us38.69 us8.5 KiB23.6 KiB
parseDicom: CT20 frames, 10 MiB10.00 MiB51.78 us193232.72 MiB/s50.71 us63.34 us132.27 us54.7 KiB94.5 KiB
parseDicom: CT200 frames, 100 MiB100.04 MiB420.40 us237964.85 MiB/s376.80 us467.48 us516.18 us459.2 KiB523.5 KiB
parseDicom, then read tags: CTsingle frame, 514 KiB513.6 KiB76.04 us6596.44 MiB/s72.19 us84.47 us177.47 us47.8 KiB86.0 KiB
parseDicom, then read tags: CT20 frames, 10 MiB10.00 MiB246.74 us40548.14 MiB/s230.81 us284.50 us435.75 us232.6 KiB319.7 KiB
parseDicom, then read tags: CT200 frames, 100 MiB100.04 MiB1.907 ms52464.66 MiB/s1.832 ms2.068 ms2.579 ms1.98 MiB2.28 MiB
serializeDicom: CTsingle frame, 514 KiB513.6 KiB47.18 us10632.38 MiB/s44.60 us261.94 us330.16 us12.9 KiB24.6 KiB
serializeDicom: CT20 frames, 10 MiB10.00 MiB1.250 ms8001.43 MiB/s463.05 us4.495 ms4.953 ms8.3 KiB38.5 KiB
serializeDicom: CT200 frames, 100 MiB100.04 MiB51.376 ms1947.22 MiB/s52.341 msnot measured: too few callsnot measured: too few calls27.1 KiB33.4 KiB
parseDicom: SR, header only50 measurements, 26 KiB26.0 KiB204.08 us124.24 MiB/s191.21 us257.17 us327.03 us114.8 KiB399.8 KiB
parseDicom: SR, header only1,000 measurements, 503 KiB503.5 KiB3.669 ms133.99 MiB/s3.662 ms3.947 msnot measured: too few calls2.00 MiB3.55 MiB
parseDicom: SR, header only10,000 measurements, 4.9 MiB4.91 MiB33.883 ms144.87 MiB/s33.935 msnot measured: too few callsnot measured: too few calls18.67 MiB15.83 MiB
parseDicom, then read tags: SR, header only50 measurements, 26 KiB26.0 KiB969.36 us26.16 MiB/s943.86 us1.123 ms1.561 ms851.4 KiB1.31 MiB
parseDicom, then read tags: SR, header only1,000 measurements, 503 KiB503.5 KiB22.125 ms22.22 MiB/s17.810 msnot measured: too few callsnot measured: too few calls16.03 MiB15.95 MiB
parseDicom, then read tags: SR, header only10,000 measurements, 4.9 MiB4.91 MiB228.674 ms21.47 MiB/s247.200 msnot measured: too few callsnot measured: too few calls160.09 MiB83.45 MiB
serializeDicom: SR, header only50 measurements, 26 KiB26.0 KiB18.71 us1354.79 MiB/s19.41 us25.04 us41.16 us6.7 KiB17.7 KiB
serializeDicom: SR, header only1,000 measurements, 503 KiB503.5 KiB38.59 us12739.80 MiB/s29.93 us235.48 us290.99 us6.7 KiB36.9 KiB
serializeDicom: SR, header only10,000 measurements, 4.9 MiB4.91 MiB1.400 ms3505.65 MiB/s1.144 ms2.172 ms2.410 ms7.3 KiB18.0 KiB

Cold import of dist/index.mjs: a median of 12.115 ms, 11.714 ms above an empty module, loading 1 files of 832.1 KiB (182.3 KiB gzipped).