Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Mutation vs non-mutation in reduce
(version: 2)
Comparing performance of:
No mutation vs With mutation
Created:
5 years ago
by:
Registered User
Jump to the latest result
Tests:
No mutation
"use strict"; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var array = new Array(999).fill(null).map(function (_, i) { return i; }); array.reduce(function (acc, item) { return Object.assign({}, acc, _defineProperty({}, item, true)); }, {}); /* const array = new Array(999).fill(null).map((_,i) => i) array.reduce((acc, item) => Object.assign({}, acc, { [item]: true }), {}) */
With mutation
"use strict"; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var array = new Array(999).fill(null).map(function (_, i) { return i; }); array.reduce(function (acc, item) { return Object.assign(acc, _defineProperty({}, item, true)); }, {}); /* const array = new Array(999).fill(null).map((_,i) => i) array.reduce((acc, item) => Object.assign(acc, { [item]: true }), {}) */
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
No mutation
With mutation
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
flatMap vs reduce using push
sort vs reduce for a few elements
flatMap vs reduce.concat vs reduce.push
flatMap vs reduce with push testtttteste212312
flatMap vs Reduce with push - test
Comments
Confirm delete:
Do you really want to delete benchmark?