Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
string.split vs toLocaleDateString("pt-PT")
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
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:
Chrome 134
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
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
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);