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.
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.
| Operation | MB/s |
|---|---|
| engine/scan | 5.0 |
| engine/transform | 5.0 |
| engine/test | 4.9 |
| engine/transform(1.x detectors) | 4.9 |
| engine/chunks/64KB | 4.7 |
| detect | 4.6 |
| stream/64KB | 4.1 |
| anonymize/redact | 3.9 |
| anonymize/mask | 3.9 |
| anonymize/consistentTokens | 3.8 |
| tokenize+detokenize | 3.8 |
| engine/chunks/lines | 3.6 |
| anonymizeAsync/hash | 2.5 |
| anonymizeBatch | 1.5 |
| stream/lines | 1.4 |
| anonymizeObject | 0.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.
| Operation | 1.0 (MB/s) | Now (MB/s) | Ratio |
|---|---|---|---|
detect | 4.6 | 4.6 | 1.00× |
hasPII | 141.5 | 139.3 | 0.98× |
anonymize/redact | 3.9 | 3.9 | 1.01× |
anonymize/mask | 3.9 | 3.9 | 1.00× |
anonymize/consistentTokens | 3.8 | 3.8 | 1.01× |
tokenize+detokenize | 3.7 | 3.8 | 1.01× |
anonymizeAsync/hash | 2.6 | 2.5 | 0.99× |
stream/lines | 1.3 | 1.4 | 1.05× |
stream/64KB | 4.1 | 4.1 | 1.01× |
anonymizeObject | 0.7 | 0.7 | 1.03× |
anonymizeBatch | 1.5 | 1.5 | 1.05× |
Cost of each detector
Time of each of the 27 detectors on 100KB of text with values of every kind.
| Category | ms |
|---|---|
| ipv6 | 2.82 |
| national-id | 2.48 |
| api-key | 1.62 |
| cryptocurrency | 1.53 |
| license-plate | 1.01 |
| drivers-license | 0.99 |
| health-insurance | 0.91 |
| tracking-number | 0.85 |
| medical-record | 0.84 |
| 0.69 | |
| vin | 0.69 |
| address | 0.65 |
| tax-id | 0.65 |
| prescription | 0.61 |
| case-number | 0.57 |
| company-registration | 0.56 |
| bank-account | 0.49 |
| date-of-birth | 0.43 |
| social-media | 0.37 |
| passport | 0.37 |
| name | 0.36 |
| credit-card | 0.22 |
| phone | 0.19 |
| iban | 0.12 |
| ssn | 0.08 |
| ipv4 | 0.06 |
| url | 0.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.
| 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.
| Call | During the call | Retained |
|---|---|---|
detect | 259 KB | 16 KB |
anonymize | 4.1 MB | 35 KB |
tokenize | 3.2 MB | 97 KB |
engine | 6.4 MB | 35 KB |