Date vs Moment.js with(out) format (v12)

Revision 12 of this benchmark created on


Description

Checking the speed of Moment.js with different options.

Preparation HTML

<script src="https://rawgithub.com/timrwood/moment/2.0.0/moment.js"></script>

Setup

function globalDoNothing () {
      var doNothing = '';
    }
    
    globalMoment = moment('2011-09-23 20:40:55.999',"YYYY-MM-DD HH:mm:ss.SSS");
    
    globalDate = new Date('2011-09-23T20:40:55.999+0000');

Test runner

Ready to run.

Testing in
TestOps/sec
Moment.js without format
moment('2011-09-23T20:40:55.999+0000');
ready
Moment.js with format
moment('2011-09-23 20:40:55.999',"YYYY-MM-DD HH:mm:ss.SSS");
ready
Logging
console.log('');
ready
Logging Date
console.log(new Date('2011-09-23T20:40:55.999+0000'));
ready
Logging Moment
console.log(moment('2011-09-23 20:40:55.999',"YYYY-MM-DD HH:mm:ss.SSS"));
ready
Parse and format
var mom = moment('2011-09-23 20:40:55.999',"YYYY-MM-DD HH:mm:ss.SSS");
mom.format('YYYY-MM-DD HH:mm:ss.SSSS');
ready
Just format
globalMoment.format('YYYY-MM-DD HH:mm:ss.SSSS');
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.