Transducers.js Round 2 with Benchmarks
jlongster.com
jlongster.com
edit: added lazy.js to the benchmark and transducers.js wins hands down. Lazy also starts way behind _/lodash and only catches up after >50k elements.
https://github.com/swannodette/mori
I would be interested to know how its transducer support and performance compares to transducers.js.
https://news.ycombinator.com/item?id=8439547
transducers in Python
http://gigasquidsoftware.com/blog/2014/09/06/green-eggs-and-...
(note this is in Clojure not JavaScript - but the ideas and usages are the same).
I do not know how this compares to a monad/monoid. If anyone can explain, please go ahead. Thx!
type Trans a b = forall r . (r -> b -> r) -> (r -> a -> r)
and it turns out that this is isomorphic to (e.g. an optimization of) the list Kleisli arrow type KleiList a b = a -> [b]
and lists are monads. For a slightly different reason, this argumentation leads me to believe that Transducers ought to be monads via the Reader/List transformer stack. I haven't verified it, however.Transducers could be monoids, too. You'd need to have two operations like so
zero :: Transducer a b
add :: Transducer a b -> Transducer a b -> Transducer a b
and perhaps there would be necessary restrictions on the choices of `a` and `b`. It's immediately obvious we could make this work if `a` and `b` were equal zero :: Transducer a a
add :: Transducer a a -> Transducer a a -> Transducer a a
as this is now just the "identity" transducer and transducer composition which satisfy all the laws of monoid.for/of solves this in JavaScript. I don't see the usability improvement this presents. I'm not being a naysayer. I hope I'm wrong here, I'm just asking.
EDIT: To clarify, plotting 'seconds' over 'items per second' is needlessly confusing.
The graph is correct - the independent variables in this case are the number of items in the array (the x axis) and the library being tested (each line).
The dependent variable in this case is time - which is why it is on the y axis.
Correct. The independent variable being the number of items and the dependent variable being the time it takes to run said number of items.
>> Time should be on the x-axis.
Time should be on the y-axis. It's the time it takes to execute, given a set of items.
> The graph below shows the time it took to run versus the size of [the array]