Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Compare vs compareLocal
(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] = 'a'; } for (var i = 0; i < 100000; i++) { arr[i] = 'b'; } 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 String(o1).localeCompare(String(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:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?