Script Preparation code:
AخA
 
var date = new Date();
window.test_results = {};
Tests:
  • Date() methods

    x
     
    let hours    = date.getHours();
    let minutes  = date.getMinutes();
    let seconds  = date.getSeconds();
    let mseconds = date.getMilliseconds();
    window.test_results['date methods'] = {hours: hours, minutes: minutes, seconds: seconds, mseconds: mseconds};
  • Individual calculations

     
    let msec     = parseInt(date, 10)
    let sec_num  = msec * 0.001;
    let hours    = Math.floor(sec_num / 3600);
    let minutes  = Math.floor((sec_num - (hours * 3600)) / 60);
    let seconds  = sec_num - (hours * 3600) - (minutes * 60);
    let mseconds = Math.floor(msec - seconds * 1000);
    window.test_results['individual calculations'] = {hours: hours, minutes: minutes, seconds: seconds, mseconds: mseconds};
  • Modulus calculations

     
    let msec     = parseInt(date, 10)
    let sec_num  = msec * 0.001;
    let hours    = Math.floor(sec_num / 3600);
    let minutes  = Math.floor((sec_num % 3600) / 60);
    let seconds  = Math.floor(sec_num % 60);
    let mseconds = Math.floor(msec % seconds);
    window.test_results['modulus calculations'] = {hours: hours, minutes: minutes, seconds: seconds, mseconds: mseconds};
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Date() methods
    Individual calculations
    Modulus calculations

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
Chrome 83 on Linux
View result in a separate tab
Test name Executions per second
Date() methods 331856.5 Ops/sec
Individual calculations 70059.4 Ops/sec
Modulus calculations 66452.6 Ops/sec