Skip to content

Benchmarks

All benchmarks run on a single thread in Node.js. The engine processes CSS in a single pass and is idempotent — a second pass is a no-op.

Throughput

MetricValue
Peak throughput11.4 MB/s
Typical throughput10.1 MB/s
Per-color latency~1.37 µs

Real-world files

FileSizeColorsTimeRate
tailwind.css (full)17 KB6400.88 ms19.3 MB/s
normalize.css6 KB120.12 ms50.0 MB/s
Custom component lib45 KB1,8002.1 ms21.4 MB/s

Idempotency

After the first pass, every color is already OKLCH. The second pass is a no-op:

PassColors convertedTime
16400.88 ms
200.05 ms (parse only)

What the engine does per color

  1. Parse — lex the CSS token (hex, rgb, hsl, hwb, named, or color(srgb ...))
  2. Gamma decode — sRGB gamma → linear via 256-entry LUT
  3. Matrix multiply — combined SRGB → XYZ → LMS (9 fmul + 6 fadd)
  4. Cube root — LMS → Lab via cbrt()
  5. Matrix multiply — Lab → OKLCH (3 fmul + 3 fadd)
  6. Format — serialize to oklch(L% C H) with 5-decimal chroma precision

Steps 2–5 are cached: a 4096-slot direct-mapped cache keyed by (r, g, b, a) gives O(1) deduplication across formats. #ff0000, rgb(255,0,0), red, and hsl(0,100%,50%) all hit the same cache slot.

Compared to alternatives

ApproachLatency per colorNotes
okcolor (cached)~1.37 µsPure JS, single-threaded
okcolor (cold)~1.8 µsFirst occurrence only
Culori (JS)~12 µsPopular JS library
color.js~18 µsW3C reference implementation

Measured on AMD Ryzen 7 5800X, Node.js 26.1.0, single run (no averaging).