array-chains
JavaScript performance comparison
Preparation code
<script src='https://cdn.jsdelivr.net/g/lodash@4(lodash.min.js+lodash.fp.min.js)'></script>
<script>
// Loading `lodash.fp.js` converts `_` to its fp variant.
_.defaults({ 'a': 2, 'b': 2 })({ 'a': 1 });
// ➜ { 'a': 1, 'b': 2 }
// Use `noConflict` to restore the pre-fp variant.
var fp = _.noConflict();
_.defaults({ 'a': 1 }, { 'a': 2, 'b': 2 });
// ➜ { 'a': 1, 'b': 2 }
fp.defaults({ 'a': 2, 'b': 2 })({ 'a': 1 });
// ➜ { 'a': 1, 'b': 2 }
</script>
<script>
Benchmark.prototype.setup = function() {
const arr = Array(1100).fill({})
.map(e => Math.random() > 0.1
? { user: { wealth: Math.random() * 1000 } }
: null);
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Test | Ops/sec | |
---|---|---|
Chain
|
|
pending… |
No-chain
|
|
pending… |
For-of
|
|
pending… |
For index
|
|
pending… |
Lodash chain
|
|
pending… |
Lodash-fp chain
|
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit
to the URL.
- Revision 1: published thoughtspile
- Revision 6: published Far Se
- Revision 7: published
- Revision 8: published
- Revision 9: published
- Revision 10: published
- Revision 11: published
- Revision 12: published
- Revision 13: published Nicolai Dahl
- Revision 14: published Nicolai Dahl
- Revision 15: published Felipe Chagas
- Revision 16: published Henrique
0 Comments