Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Compare vs compareLocal V2
(version: 1)
Comparing performance of:
Compare local vs compare
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
var arrA = []; var arrB = []; for (var i = 0; i < 100000; i++) { arr[i] = 'T021AV0C'; } for (var i = 0; i < 100000; i++) { arr[i] = 'T021ACVC'; } function compareLocal(o1, o2) { if (o1 === o2) { return 0; } // undefined is lower than any value if (o1 === undefined) { return -1; } if (o2 === undefined) { return 1; } // null is lower than any value except undefined if (o1 === null) { return -1; } if (o2 === null) { return 1; } return o1.localeCompare(o2, undefined, options); } function compare(o1, o2) { if (o1 === o2) { return 0; } // undefined is lower than any value if (o1 === undefined) { return -1; } if (o2 === undefined) { return 1; } // null is lower than any value except undefined if (o1 === null) { return -1; } if (o2 === null) { return 1; } return o1 < o2 ? -1 : 1; }
Tests:
Compare local
for(var i = 0; i<100000;i++){ compareLocal(arrA[i],arrB[i]); }
compare
for(var i = 0; i<100000;i++){ compare(arrA[i],arrB[i]); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Compare local
compare
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Compare local
2390.8 Ops/sec
compare
2357.5 Ops/sec
Related benchmarks:
arguments vs array arg
arguments vs array arg
arguments vs array arg
undefined vs. typeof vs. in vs. hasOwnProperty vs wrapped function
Multiple Nil checks 0.8
Deep equal
localeCompare vs charCodeAt
Another lodash isEqual test
Javascript array deducplication.
Comments
Confirm delete:
Do you really want to delete benchmark?