Skip to main content

Benchmarks

JS Layout Engine Performance

Measured on the JS heuristic layout engine (@hexdrinker/pretext-native-core). Native measurement (iOS CoreText / Android StaticLayout) bypasses JS tokenization entirely and is faster.

ScenarioColdWarm (cached)
Short text (13 chars)815K ops/s5.8M ops/s
Medium text (180 chars)112K ops/s2.3M ops/s
Long text (1.2K chars)17K ops/s503K ops/s
CJK text (120 chars)159K ops/s2.7M ops/s

Warm cache = 2–5M ops/s — fast enough to measure thousands of items per frame at 60fps.

How to Reproduce

cd packages/core && npx ts-node benchmark/run.ts

Results vary by hardware. Numbers above were measured on Apple M-series.

Feature Comparison

onLayoutreact-native-text-sizepretext-native
Pre-render measurementNoYesYes
Synchronous API (JSI)NoNoYes
getItemLayout supportNoManualBuilt-in
Built-in cacheN/ANoYes (95%+ hit rate)
allowFontScalingN/AYesYes
Custom font validationN/ANoYes (isFontAvailable)
TurboModule (New Arch)N/ANoYes
Package size0 (built-in)167KB13KB (core) + 120KB
Runtime dependenciesN/A00

How We Verified

  • Package size: npm pack output for each package
  • react-native-text-size: npm info react-native-text-size and GitHub README for API/feature verification
  • Benchmark: cd packages/core && npx ts-node benchmark/run.ts

All claims are reproducible. If you find any inaccuracy, please open an issue.