Skip to main content
Version: v0.1.17

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.17 at commit fb26719 on 2026-11-28, 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-28: 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 KiB8.93 us114.33 MiB/s8.27 us13.65 us24.45 us7.9 KiB23.0 KiB
parseDicom, then read tags: worklist item1 KiB1.0 KiB24.35 us41.90 MiB/s23.80 us32.19 us46.44 us23.3 KiB47.0 KiB
serializeDicom: worklist item1 KiB1.0 KiB8.21 us124.28 MiB/s7.93 us8.95 us16.72 us9.3 KiB21.1 KiB
parseDicom: CTsingle frame, 514 KiB513.6 KiB15.77 us31812.05 MiB/s14.70 us24.03 us37.24 us7.7 KiB22.9 KiB
parseDicom: CT20 frames, 10 MiB10.00 MiB52.54 us190431.71 MiB/s49.20 us60.77 us128.36 us54.7 KiB93.8 KiB
parseDicom: CT200 frames, 100 MiB100.04 MiB395.81 us252748.78 MiB/s377.54 us469.50 us502.36 us458.5 KiB522.1 KiB
parseDicom, then read tags: CTsingle frame, 514 KiB513.6 KiB46.07 us10887.73 MiB/s44.57 us54.06 us126.57 us40.7 KiB72.9 KiB
parseDicom, then read tags: CT20 frames, 10 MiB10.00 MiB154.18 us64891.36 MiB/s148.61 us172.68 us306.60 us180.3 KiB268.6 KiB
parseDicom, then read tags: CT200 frames, 100 MiB100.04 MiB1.304 ms76700.76 MiB/s1.240 ms1.641 ms1.936 ms1.53 MiB1.90 MiB
serializeDicom: CTsingle frame, 514 KiB513.6 KiB40.07 us12518.05 MiB/s38.12 us48.39 us125.41 us15.5 KiB27.6 KiB
serializeDicom: CT20 frames, 10 MiB10.00 MiB3.343 ms2992.36 MiB/s2.709 ms4.790 msnot measured: too few calls64.5 KiB94.3 KiB
serializeDicom: CT200 frames, 100 MiB100.04 MiB54.863 ms1823.46 MiB/s55.489 msnot measured: too few callsnot measured: too few calls575.7 KiB564.4 KiB
parseDicom: SR, header only50 measurements, 26 KiB26.0 KiB200.38 us126.53 MiB/s187.82 us230.81 us335.34 us103.6 KiB462.7 KiB
parseDicom: SR, header only1,000 measurements, 503 KiB503.5 KiB3.564 ms137.96 MiB/s3.587 ms3.812 msnot measured: too few calls1.85 MiB3.23 MiB
parseDicom: SR, header only10,000 measurements, 4.9 MiB4.91 MiB36.075 ms136.06 MiB/s35.932 msnot measured: too few callsnot measured: too few calls18.63 MiB15.83 MiB
parseDicom, then read tags: SR, header only50 measurements, 26 KiB26.0 KiB603.19 us42.03 MiB/s575.95 us703.37 us961.84 us587.0 KiB1.03 MiB
parseDicom, then read tags: SR, header only1,000 measurements, 503 KiB503.5 KiB12.243 ms40.16 MiB/s11.825 msnot measured: too few callsnot measured: too few calls11.17 MiB14.23 MiB
parseDicom, then read tags: SR, header only10,000 measurements, 4.9 MiB4.91 MiB156.086 ms31.45 MiB/s154.230 msnot measured: too few callsnot measured: too few calls112.01 MiB76.01 MiB
serializeDicom: SR, header only50 measurements, 26 KiB26.0 KiB184.10 us137.72 MiB/s172.61 us247.25 us273.15 us303.5 KiB315.2 KiB
serializeDicom: SR, header only1,000 measurements, 503 KiB503.5 KiB3.702 ms132.80 MiB/s3.968 ms5.251 msnot measured: too few calls5.77 MiB5.80 MiB
serializeDicom: SR, header only10,000 measurements, 4.9 MiB4.91 MiB51.403 ms95.49 MiB/s51.107 msnot measured: too few callsnot measured: too few calls57.64 MiB15.74 MiB

Cold import of dist/index.mjs: a median of 12.666 ms, 12.242 ms above an empty module, loading 1 files of 823.0 KiB (180.6 KiB gzipped).