jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Provide pipe as an alternative to chain.
Pros:
Cons:
For what it's worth it employs pointfree style which is preferred for reasons of its own.
http://www.haskell.org/haskellwiki/Pointfree
<script src='http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js'></script>
<script>
function pipe(seed){
var seeded = arguments.length > 0, composed = [];
return function piping(verb){
if (arguments.length === 0) {
var fn = _.compose.apply(null, composed);
return seeded ? fn(seed) : fn;
}
var args = _.rest(arguments);
composed.unshift(function(obj){
return verb.apply(null, [obj].concat(args));
});
return piping;
}
};
_.pipe = pipe;
var chainCounter = function(lyrics) {
return _(lyrics).chain()
.map(function(line) { return line.words.split(' '); })
.flatten()
.reduce(function(counts, word) {
counts[word] = (counts[word] || 0) + 1;
return counts;
}, {})
.value();
};
var pipeCounter = _.pipe()
(_.map, function(line) { return line.words.split(' '); })
(_.flatten)
(_.reduce, function(counts, word) {
counts[word] = (counts[word] || 0) + 1;
return counts;
}, {})
();
</script>
var lyrics = [{line: 1, words: "I'm a lumberjack and I'm okay"},
{line: 2, words: "I sleep all night and I work all day"},
{line: 3, words: "He's a lumberjack and he's okay"},
{line: 4, words: "He sleeps all night and he works all day"}];
Ready to run.
Test | Ops/sec | |
---|---|---|
Chain |
| ready |
Pipe |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.