Skip to content

Commit

Permalink
fix: map-filter-reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
ilteoood committed Jun 21, 2024
1 parent 64966a0 commit c8f283c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion benchmarks/map-filter-reduce.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@ describe("map-filter-reduce", () => {
const initialArray = new Array(10_000).fill(0).map((_, index) => index);

bench("normal", () => {
initialArray
const result = initialArray
.map((value) => value * 2)
.filter((value) => value % 2 === 0)
.reduce((accumulator, value) => accumulator + value, 0);
});

bench("re-flusso", async () => {
let result: number;

await pipeline(
fromIterable(initialArray),
map((value) => value * 2),
filter((value) => value % 2 === 0),
sum(),
forEach<number>((sumResult) => {
result = sumResult;
}),
);
});
});

0 comments on commit c8f283c

Please sign in to comment.