Skip to content

zach-betz-hln/mre-reduce-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mre-reduce-playground

For testing .reduce variants. Inspired by noAccumulatingSpread.

Setup

  1. Install Node.js v22+
  2. Install deps: npm i
  3. Run it: npm run dev

Benchmarks

Each variant does the same thing: it maps 300k rows to an object.

Notice how withReduceSpreadAccumulator takes way longer than the other variants.

Ran on a 2021 MacBook Pro Apple M1 Max. Your results may vary.

withForOf: 17.737ms
withFilterAndMapAndFromEntries: 15.524ms
withReduceMutateAccumulator: 8.428ms
withReduceSpreadAccumulator: 31.500s

About

For testing .reduce variants

Resources

Stars

Watchers

Forks