Created
January 1, 2022 19:46
-
-
Save ole-magnus/a22be50e5091957235e5a06a9e6a43e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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