momentjs vs datejs

JavaScript performance comparison

Revision 7 of this test case created by Scott Yang

Info

moment.js and date.js are 2 libraries offering similar functionalities that is lacking in basic javascript.

Results on Chrome: moment.js is lighter, and offers much faster parsing. On the other hand, date.js offers much faster formatting and manipulation.

Preparation code

<script src="http://datejs.googlecode.com/files/date.js"></script>
<script src="https://raw.github.com/timrwood/moment/2.0.0/min/moment.min.js"></script>
<script>
  var DateJS = new Date();
  var momentJS = moment();
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
moment.js parse
moment('07-10-1986', 'MM-DD-YYYY');
pending…
DateJS parse
Date.parse('07-10-1986', "MM-dd-yyyy");
pending…
moment.js format
momentJS.format('MM-DD-YYYY h:mm:ss a');
pending…
DateJS format
DateJS.toString('MM-dd-yyyy h:mm:ss t');
pending…
moment.js manipulation
momentJS.add({ days: 5, months: 3 });
pending…
DateJS manipulation
DateJS.add({ days: 5, months: 3 });
pending…
moment.js Overall
moment('07-10-1986', 'MM-DD-YYYY').add({ days: 5 }).format('MM-DD-YYYY h:mm:ss a');
pending…
DateJS Overall
Date.parse('07-10-1986', "MM-dd-yyyy").add({ days: 5 }).toString('MM-dd-yyyy h:mm:ss t');
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment