Skip to main content
Version: v0.1.18

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.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.

BenchmarkSizeInputPer callThroughputp50p95p99Allocated per callPeak heap
parseDicom: worklist item1 KiB1.0 KiB11.57 us88.16 MiB/s10.67 us20.58 us38.99 us7.9 KiB23.0 KiB
parseDicom, then read tags: worklist item1 KiB1.0 KiB34.72 us29.39 MiB/s33.41 us47.43 us81.51 us22.1 KiB47.0 KiB
serializeDicom: worklist item1 KiB1.0 KiB10.79 us94.57 MiB/s11.12 us13.98 us24.59 us9.3 KiB21.1 KiB
parseDicom: CTsingle frame, 514 KiB513.6 KiB24.49 us20479.76 MiB/s19.68 us31.78 us56.23 us7.8 KiB22.9 KiB
parseDicom: CT20 frames, 10 MiB10.00 MiB80.58 us124160.68 MiB/s75.36 us128.92 us209.37 us54.5 KiB93.9 KiB
parseDicom: CT200 frames, 100 MiB100.04 MiB625.61 us159906.63 MiB/s569.90 us720.79 us815.87 us458.4 KiB524.3 KiB
parseDicom, then read tags: CTsingle frame, 514 KiB513.6 KiB72.75 us6895.26 MiB/s67.20 us84.64 us198.49 us40.5 KiB72.1 KiB
parseDicom, then read tags: CT20 frames, 10 MiB10.00 MiB243.09 us41156.47 MiB/s211.04 us256.86 us446.00 us180.5 KiB271.0 KiB
parseDicom, then read tags: CT200 frames, 100 MiB100.04 MiB1.834 ms54536.77 MiB/s1.700 ms2.357 ms2.687 ms1.50 MiB1.91 MiB
serializeDicom: CTsingle frame, 514 KiB513.6 KiB65.18 us7695.17 MiB/s64.02 us76.30 us197.17 us15.5 KiB27.6 KiB
serializeDicom: CT20 frames, 10 MiB10.00 MiB1.941 ms5154.70 MiB/s1.004 ms5.243 ms5.502 ms63.5 KiB94.3 KiB
serializeDicom: CT200 frames, 100 MiB100.04 MiB66.536 ms1503.55 MiB/s66.727 msnot measured: too few callsnot measured: too few calls586.4 KiB564.4 KiB
parseDicom: SR, header only50 measurements, 26 KiB26.0 KiB298.72 us84.88 MiB/s291.66 us397.75 us502.06 us108.7 KiB424.0 KiB
parseDicom: SR, header only1,000 measurements, 503 KiB503.5 KiB5.115 ms96.13 MiB/s4.918 ms5.378 msnot measured: too few calls1.85 MiB3.47 MiB
parseDicom: SR, header only10,000 measurements, 4.9 MiB4.91 MiB50.956 ms96.33 MiB/s48.475 msnot measured: too few callsnot measured: too few calls18.95 MiB15.82 MiB
parseDicom, then read tags: SR, header only50 measurements, 26 KiB26.0 KiB828.11 us30.62 MiB/s797.94 us969.75 us1.264 ms589.5 KiB1.07 MiB
parseDicom, then read tags: SR, header only1,000 measurements, 503 KiB503.5 KiB17.054 ms28.83 MiB/s16.383 msnot measured: too few callsnot measured: too few calls10.70 MiB14.27 MiB
parseDicom, then read tags: SR, header only10,000 measurements, 4.9 MiB4.91 MiB224.752 ms21.84 MiB/s223.164 msnot measured: too few callsnot measured: too few calls112.00 MiB76.03 MiB
serializeDicom: SR, header only50 measurements, 26 KiB26.0 KiB249.75 us101.52 MiB/s237.30 us336.45 us377.94 us303.5 KiB315.2 KiB
serializeDicom: SR, header only1,000 measurements, 503 KiB503.5 KiB5.567 ms88.32 MiB/s5.344 ms6.391 msnot measured: too few calls5.77 MiB5.80 MiB
serializeDicom: SR, header only10,000 measurements, 4.9 MiB4.91 MiB59.402 ms82.63 MiB/s58.585 msnot measured: too few callsnot measured: too few calls57.64 MiB15.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).