Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
LocaleCompare vs My sorting
(version: 1)
Comparing performance of:
Locale compare vs My version
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
var string1 = "Lucy Aligtore"; var string2 = "Fridolin Bauer";
Tests:
Locale compare
string1.localeCompare(string2);
My version
const s1 = string1 ? [...string1.toLowerCase()].reduce((prev, char) => prev + char.charCodeAt(0), 0) : 0; const s2 = string2 ? [...string2.toLowerCase()].reduce((prev, char) => prev + char.charCodeAt(0), 0) : 0; string1 && string2 ? Math.sign(s1 - s2) : Math.sign(s2 - s1);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Locale compare
My version
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Browser/OS:
Chrome 133 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Locale compare
102183960.0 Ops/sec
My version
5147244.0 Ops/sec
Related benchmarks:
string comparation
Compare string equals performance
Intl.Collator.compare() vs localeCompare() no options sort
Collator vs LocaleCompare test with sort
Compare string equals performance without case diffs
Intl.Collator.compare() lowercase vs sensitivity #2
Intl.Collator.compare() lowercase vs sensitivity #3
Intl.Collator.compare() lowercase vs sensitivity #4
Intl.Collator.compare() lowercase vs sensitivity vs localeCompare
Comments
Confirm delete:
Do you really want to delete benchmark?