Skip to content

hckhanh/js-utils-benchmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

js-utils-benchmark

License: MIT Bun mitata

Bundle-size, performance, tree-shaking and DX comparison of seven JavaScript utility libraries — lodash, lodash-es, es-toolkit, radashi, remeda, rambda, moderndash.

📊 Read the full report → REPORT.md


TL;DR

Concern Winner
📦 Smallest whole-lib (gzip) moderndash (4.8 KB) → rambda (6.1 KB) → es-toolkit (9.2 KB)
📦 Smallest realistic 5-fn app moderndash (702 B) → radashi (850 B)
⚡ Most perf wins (12 benches) moderndash (4) → es-toolkit / radashi (3 each)
🌳 Best tree-shaking es-toolkit, radashi, remeda, rambda, moderndash (all ✅)
🔤 TypeScript-first es-toolkit, remeda, radashi, moderndash
🏛️ Drop-in lodash compat lodash (still) or es-toolkit/compat
📈 Adoption (npm DL/wk) lodash (149 M) → lodash-es (33 M) → es-toolkit (23 M)

Full numbers, methodology, and per-function breakdowns in REPORT.md.


What it measures

  1. Performancemitata 1.0 micro-benchmarks across 12 common functions (chunk, groupBy, uniq, cloneDeep, isEqual, pick, omit, difference, intersection, camelCase, get, debounce).
  2. Bundle size — single-function imports + 5-function realistic-app scenario, minified by Bun.build, then gzip / brotli / zstd.
  3. Tree-shaking — single-fn-bundle ÷ whole-lib-bundle ratio.
  4. DX & quality — TypeScript types, ESM/CJS, exports map, sideEffects flag, dependency count, FP style, public-function count.
  5. Ecosystem — GitHub stars/forks/issues + npm weekly downloads.

Requirements

  • Bun ≥ 1.3
  • macOS / Linux / Windows (any platform Bun runs on)
  • (Optional) gh CLI for refreshing ecosystem data

Quick start

git clone https://github.com/hckhanh/js-utils-benchmark.git
cd js-utils-benchmark
bun install
bun run all          # ≈ 5 min — runs everything → REPORT.md

Or piecewise:

bun run quality      # → results/quality.json
bun run bundle       # → results/bundle.json + bundle-realistic.json
bun run bench        # → results/bench.json (slow, ~3 min)
bun run report       # → REPORT.md

Layout

src/
  data.ts                     shared test fixtures
  benchmarks/run.ts           mitata perf suite (12 fns × 7 libs)
  bundle/measure.ts           per-fn raw / min / gzip / brotli / zstd
  bundle/realistic.ts         5-fn "real app" scenario
  quality/score.ts            DX matrix from package.json + types walk
  report.ts                   stitches every JSON → REPORT.md
results/                      raw outputs (json, committed)
REPORT.md                     final report

Refreshing ecosystem data

results/ecosystem.json (GitHub stats + npm downloads) is fetched manually:

gh api repos/<owner>/<repo> --jq '{stars:.stargazers_count, forks:.forks_count, openIssues:.open_issues_count, pushed:.pushed_at, lic:.license.spdx_id}'
curl -s https://api.npmjs.org/downloads/point/last-week/<pkg> | jq '.downloads'

Then bun run report re-renders.

Contributing

PRs welcome — especially for:

  • Adding a new library to the matrix (just edit the seven LIBS arrays in src/{benchmarks,bundle,quality} and re-run).
  • Adding a missing function to the perf suite.
  • Re-running on a different machine and posting your numbers as an issue.

When adding a library:

  1. bun add <new-lib>
  2. Map its function names in src/bundle/measure.ts and src/benchmarks/run.ts (skip with "" if a fn isn't available — the runner handles it).
  3. Add an entry to FP_STYLE in src/quality/score.ts and the LIBS order in src/report.ts.
  4. bun run all and commit the regenerated REPORT.md and results/*.json.

Methodology notes

  • Numbers are from a single Apple-silicon Mac running Bun 1.3.13. Re-run on your hardware for your bundler/runtime to get representative numbers.
  • mitata uses JIT-warmup + GC instrumentation and runs 4096 ops per sample. do_not_optimize prevents dead-code elimination.
  • rambda v11+ is fully auto-curriedequals(a, b) returns a function; benchmarks use equals(a)(b) to actually compute.
  • radashi ships both clone (shallow) and cloneDeep — the cloneDeep benchmark uses the deep one for fairness.

License

MIT © 2026 Khánh Hoàng

About

Bundle-size, perf, tree-shaking & DX comparison of 7 JS utility libs (lodash, lodash-es, es-toolkit, radashi, remeda, rambda, moderndash). Bun + mitata.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors