Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
parse date
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 135
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
Regex
11373.5 Ops/sec
Substr
13741.2 Ops/sec
Script Preparation code:
var REGEX = /^(\d{4})-(\d{2})-(\d{2})(T(\d{2}):(\d{2})(:(\d{2}))?)?/; function withRegex(str) { var match = str.match(REGEX); if (match) { return new Date(match[1], match[2], match[3], match[5] || 0, match[6] || 0, match[8] || 0); } return null; } function withSubstr(str) { var year = parseInt(str.substr(0, 4), 10), month = parseInt(str.substr(5, 2), 10) - 1, day = parseInt(str.substr(8, 2), 10), hour = 0, minute = 0, second = 0; if (str.indexOf('T') > -1) { hour = parseInt(str.substr(11, 2), 10), minute = parseInt(str.substr(14, 2), 10), second = parseInt(str.substr(17, 2), 10); } return new Date(year, month, day, hour, minute, second); }
Tests:
Regex
for (var i=0; i<100; ++i) { withRegex('1991-11-26T12:00:00'); withRegex('1991-11-26'); }
Substr
for (var i=0; i<100; ++i) { withSubstr('1991-11-26T12:00:00'); withSubstr('1991-11-26'); }