Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array.every vs JSON.stringify vs foreach
(version: 1)
Comparing performance of:
JSON.stringify vs Array.every vs foreach
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
window.foo = ['cat', 'dog', 'bird']; window.bar = ['cat', 'dog', 'bird'];
Tests:
JSON.stringify
JSON.stringify(window.foo) === JSON.stringify(window.bar);
Array.every
window.foo.every((item, index) => item === window.bar[index])
foreach
window.foo.forEach(f => window.bar.indexOf(f) != -1)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
JSON.stringify
Array.every
foreach
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
11 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:138.0) Gecko/20100101 Firefox/138.0
Browser/OS:
Firefox 138 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
JSON.stringify
1778861.0 Ops/sec
Array.every
1385847.8 Ops/sec
foreach
1603334.1 Ops/sec
Related benchmarks:
_.isEqual vs toString() vs JSON.stringify
Test on isEqual performance with array of objects
Test on isEqual performance with array of objects and customiser
Array.every vs JSON.stringify
Lodash.isEqual vs JSON.stringify vs direct comparision of two elements
filter-includes vs JSON.stringify Equality Comparison for Shallow Array of Strings.
Lodash.isEqual vs JSON.stringify
Stringify vs toString vs array stringify
Array.every vs JSON.stringify2123
Comments
Confirm delete:
Do you really want to delete benchmark?