Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
string.split vs toLocaleDateString("pt-PT")
(version: 1)
Comparing performance of:
split vs Date toLocaleString vs slice vs substring
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var dateStr = "2021-08-10"
Tests:
split
const [yyyy, mm, dd] = dateStr.split("/"); const result =`${dd}/${mm}/${yyyy}`;
Date toLocaleString
const result = new Date(dateStr).toLocaleString("pt-PT");
slice
const day = dateStr.slice(8, 10); const month = dateStr.slice(5, 7); const year = dateStr.slice(0, 4);
substring
const day = dateStr.substring(8, 10); const month = dateStr.substring(5, 7); const year = dateStr.substring(0, 4);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
split
Date toLocaleString
slice
substring
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/134.0.0.0 Safari/537.36 Edg/134.0.0.0
Browser/OS:
Chrome 134 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
split
9273335.0 Ops/sec
Date toLocaleString
226367.2 Ops/sec
slice
57741608.0 Ops/sec
substring
59513728.0 Ops/sec
Related benchmarks:
Date.parse vs custom
toLocalDateString vs Array index
String split date vs parse date
String split date vs parse date 2
String split date vs parse date 3
string.split vs toLocaleString("en-GB")
toLocaleDateString_perf
split vs slice date ranges for cally
string.split vs string.substring vs toLocaleDateString("pt-PT") vs Intl.DateTimeateTimeFormat
Comments
Confirm delete:
Do you really want to delete benchmark?