Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
equivalent arrays
(version: 0)
Comparing performance of:
little pyramid vs big pyramid
Created:
5 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
function equivalent(arr1, arr2) { if (arr1.length !== arr2.length) { return false } arr1.forEach((elem) => { const index = arr2.findIndex((elem2) => elem === elem2) if (index === -1) { // not found return false } arr2.splice(index, 1) // remove element }) if (arr2.length > 0) { // if still values in arr2, they are not in arr1 return false } return true }
Tests:
little pyramid
const res = equivalent([1, 2, 3, 4, 5], [5, 4, 3, 2, 1]) console.log(res)
big pyramid
const array1 = [] const array2 = [] for (let i = 0; i <= 100; i++) { array1.push(i) } for (let i = 99; i >= 0; i--) { array1.push(i) } const res = equivalent(array1, array2) console.log(res)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
little pyramid
big pyramid
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:
_.filter vs Array.filter
Intersection filter vs lodash intersection test unsorted array
Number array indexOf vs includes vs some vs find vs for
Number array indexOf vs includes vs some vs find vs for vs in
array.indexOf vs array.includes vs array.some vs equality
Comments
Confirm delete:
Do you really want to delete benchmark?