Skip to main content

Benchmarks

Measured with bench/run.mjs on Node.js v25.9.0, Intel(R) Core(TM) i5-10400F CPU @ 2.90GHz (12 threads). Absolute numbers depend on the machine; compare ratios and slopes. Inputs are synthetic, with one value to replace per 200 characters (“sparse”). How it is measured.

5.0 MB/sspan engine, transform, 100KB
3.9 MB/s1.0 anonymize(), 100KB
18 of 18span-engine operations linear in input size (slope ≤ 1.1)

Throughput at 100KB

hasPII() stops at the first value it finds, so it is left out: on text with values it answers in 0.72 ms.

Throughput of each operation on 100KB of sparse text
OperationMB/s
engine/scan5.0
engine/transform5.0
engine/test4.9
engine/transform(1.x detectors)4.9
engine/chunks/64KB4.7
detect4.6
stream/64KB4.1
anonymize/redact3.9
anonymize/mask3.9
anonymize/consistentTokens3.8
tokenize+detokenize3.8
engine/chunks/lines3.6
anonymizeAsync/hash2.5
anonymizeBatch1.5
stream/lines1.4
anonymizeObject0.7

Against 1.0

The same operations on the same inputs, in anonyma 1.0.0 and in the current build. A ratio above 1 is faster now.

Operation1.0 (MB/s)Now (MB/s)Ratio
detect4.64.61.00×
hasPII141.5139.30.98×
anonymize/redact3.93.91.01×
anonymize/mask3.93.91.00×
anonymize/consistentTokens3.83.81.01×
tokenize+detokenize3.73.81.01×
anonymizeAsync/hash2.62.50.99×
stream/lines1.31.41.05×
stream/64KB4.14.11.01×
anonymizeObject0.70.71.03×
anonymizeBatch1.51.51.05×

Cost of each detector

Time of each of the 27 detectors on 100KB of text with values of every kind.

Median time of each detector on 100 KB
Categoryms
ipv62.82
national-id2.48
api-key1.62
cryptocurrency1.53
license-plate1.01
drivers-license0.99
health-insurance0.91
tracking-number0.85
medical-record0.84
email0.69
vin0.69
address0.65
tax-id0.65
prescription0.61
case-number0.57
company-registration0.56
bank-account0.49
date-of-birth0.43
social-media0.37
passport0.37
name0.36
credit-card0.22
phone0.19
iban0.12
ssn0.08
ipv40.06
url0.03

Scaling

The slope of log(time) against log(size), from 100 B to 1 MB: 1.0 means the time grows in proportion to the input. The span engine stays linear; the 1.x anonymize() family grows faster on text with many values (up to 1.42), which is one reason to compile a pipeline for large inputs.

Scaling slope of each operation
Operation (density)slope
detect (none)0.94
detect (sparse)0.94
detect (dense)0.95
hasPII (none)0.94
hasPII (sparse)1.00
hasPII (dense)1.02
anonymize/redact (none)0.94
anonymize/redact (sparse)1.23
anonymize/redact (dense)1.40
anonymize/mask (none)0.94
anonymize/mask (sparse)1.23
anonymize/mask (dense)1.42
anonymize/consistentTokens (none)0.94
anonymize/consistentTokens (sparse)1.23
anonymize/consistentTokens (dense)1.40
tokenize+detokenize (none)0.94
tokenize+detokenize (sparse)1.23
tokenize+detokenize (dense)1.40
anonymizeAsync/hash (none)0.90
anonymizeAsync/hash (sparse)0.96
anonymizeAsync/hash (dense)1.03
stream/lines (none)0.99
stream/lines (sparse)0.99
stream/lines (dense)0.98
stream/64KB (none)0.98
stream/64KB (sparse)1.00
stream/64KB (dense)1.05
engine/scan (none)0.94
engine/scan (sparse)0.94
engine/scan (dense)0.94
engine/test (none)0.94
engine/test (sparse)0.94
engine/test (dense)0.95
engine/transform (none)0.94
engine/transform (sparse)0.94
engine/transform (dense)0.95
engine/transform(1.x detectors) (none)0.94
engine/transform(1.x detectors) (sparse)0.94
engine/transform(1.x detectors) (dense)0.95
engine/chunks/lines (none)0.99
engine/chunks/lines (sparse)1.00
engine/chunks/lines (dense)0.99
engine/chunks/64KB (none)0.96
engine/chunks/64KB (sparse)0.96
engine/chunks/64KB (dense)0.97
anonymizeObject (sparse)1.04
anonymizeBatch (sparse)0.99

Memory

Heap growth during one call on 100 KB (garbage included), and what stays allocated after a collection. Streaming 50.0 MB in line-sized chunks peaked at 71.2 MB of heap growth, at 1.5 MB/s.

CallDuring the callRetained
detect259 KB16 KB
anonymize4.1 MB35 KB
tokenize3.2 MB97 KB
engine6.4 MB35 KB