Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Date with modulo
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Browser:
Chrome 119
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Test case 1
3721.1 Ops/sec
Test case number 2
6757402.0 Ops/sec
Tests:
Test case 1
const SECONDS_PER_MINUTE = 60; const SECONDS_PER_HOUR = 60 * SECONDS_PER_MINUTE; const SECONDS_PER_DAY = 24 * SECONDS_PER_HOUR; const DAYS_PER_YEAR = 365; const DAYS_PER_LEAP_YEAR = DAYS_PER_YEAR + 1; const EPOCH_MONTH = 1; const EPOCH_YEAR = 1970; function getDateTime(timestamp) { let days = ~~(timestamp / SECONDS_PER_DAY); let year = EPOCH_YEAR; while (days >= getDaysForYear(year)) { days -= getDaysForYear(year); year++; } let daysPerMonth = getDaysPerMonth(year); let month = EPOCH_MONTH; while (days >= daysPerMonth[month]) { days -= daysPerMonth[month]; month++; } let day = days + 1; let secondsRemaining = timestamp % SECONDS_PER_DAY; let hour = ~~(secondsRemaining / SECONDS_PER_HOUR); let minute = ~~(secondsRemaining / SECONDS_PER_MINUTE) % SECONDS_PER_MINUTE; let second = secondsRemaining % SECONDS_PER_MINUTE; return { year, month, day, hour, minute, second }; } function isLeapYear(year) { return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0); } function getDaysForYear(year) { return isLeapYear(year) ? DAYS_PER_LEAP_YEAR : DAYS_PER_YEAR; } function getDaysPerMonth(year) { return [ 0, 31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]; } const currentDatetime = Date.now(); const { year, month, day, hour, minute, second } = getDateTime( currentDatetime );
Test case number 2
const pad = number => { if (number < 10) { return `0${number}`; } return number; }; const currentDatetime = new Date(); const year = currentDatetime.getUTCFullYear(); const month = pad(currentDatetime.getUTCMonth() + 1); const day = pad(currentDatetime.getUTCDate()); const hour = pad(currentDatetime.getUTCHours()); const minutes = pad(currentDatetime.getUTCMinutes()); const seconds = pad(currentDatetime.getUTCSeconds());