Comments (4)
So I tested the difference between using for of
, and interacting with the iterator via next()
and the difference was huge. In favor of the direct interaction. Using the for of
was significantly slower for even small arrays. It was odd because when using for of
it didn't seem to benefit from the deferred execution at all. So as the original array size increased, so did the time it took to execute the method chain. The same was not true when using direct interaction with the next()
function.
from ts-lazy-collections.
I didn't run any tests, but my gut says:
- on small collections this is faster due to having less iterators (which have a considerable overhead)
- on big collections it is slower because the
...
operator (shallowly) clones all the items in the collection which at some point will cost more resources then the gains of having less iterators
But this is just speculation, the only way to know for sure it to test a variety of cases. Properly will also depend on the runtime you are using as iterators are a recent addition and I expect more modern runtimes to have more efficient implementations of them.
from ts-lazy-collections.
Not sure what you mean, I didn't really use ...
much. Only in arguments, but I could as well take arrays in those two cases.
Oh, if you mean c
the currying function, then sure, it's probably bad news, and I should just rewrite the functions as eg
const filter = p => function* filter(it) {
for (const x of it) if (p(x)) yield fn(x);
}
But I meant the fact that you manually called .next()
a lot.
I'd assume the for
optimizes better, even for manual implementations of iterator?
from ts-lazy-collections.
Lets make benchmark
from ts-lazy-collections.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ts-lazy-collections.