Skip to content

Instantly share code, notes, and snippets.

@ole-magnus
Created January 1, 2022 19:46
Show Gist options
  • Save ole-magnus/a22be50e5091957235e5a06a9e6a43e3 to your computer and use it in GitHub Desktop.
Save ole-magnus/a22be50e5091957235e5a06a9e6a43e3 to your computer and use it in GitHub Desktop.
import { add, complete, cycle, suite } from 'benny';
import { chainFrom } from 'transducist';
const arr = Array.from(Array(10000).keys());
suite(
'Pipelines',
add('array API', () => {
arr
.map(i => ++i)
.filter(i => i % 2 === 0)
.reduce((a,b) => a + b, 0)
}),
add('transducist', () => {
chainFrom(arr)
.map(i => ++i)
.filter(i => i % 2 === 0)
.reduce((a,b) => a + b, 0)
}),
cycle(),
complete(),
);
/**
❯ yarn run start
yarn run v1.22.17
warning ../../../package.json: No license field
$ ts-node src/index.ts
Running "Pipelines" suite...
Progress: 100%
array API:
11 159 ops/s, ±14.73% | slowest, 67.43% slower
transducist:
34 260 ops/s, ±20.99% | fastest
Finished 2 cases!
Fastest: transducist
Slowest: array API
Done in 11.31s.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment