-
Notifications
You must be signed in to change notification settings - Fork 8
Simpler and faster filtering, mapping, skipping and limiting #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@RubenVerborgh if you like where this is going I can spend some time refining those new iterators (cleaning up event handlers, implementing |
|
#50 is still about |
|
With main as it is right now, after merging #46 , going through the following chain takes ~210 ms with an array of 200k items (MacBook Pro, Apple Silicon, M1, 16 GB RAM). With this PR that goes down to ~30 ms, so roughly 7x faster. new ArrayIterator(arr)
.map((item: number) => item)
.map((item: number) => item)
.map((item: number) => item)
.map((item: number) => item)
.map((item: number) => item)
.map((item: number) => item)
.map((item: number) => item)
.map((item: number) => item)
.map((item: number) => item)
.map((item: number) => item) |
|
@RubenVerborgh this should be in a better place now. Those new iterators likely deserve dedicated tests but before that, should anything more be done In |
|
Superseded by #57 |
While researching #44 , @jeswr discovered that the performance of
.map()and.filter()could be greatly improved by adding simple dedicated iterators for mapping and filtering, respectively. The impact of using these simplified iterators grows with the length of the chain of iterators.As measured on a 13'' 2020 MacBook Pro (Apple Silicon, M1, 16 GB RAM), this PR makes the following test run in ~30ms. Before this PR the same test would terminate after ~300ms - a 10x difference.
Note that the
RangeIteratorclass is just a stopgap for #47 .