Native Date Vs Moment.js

JavaScript performance comparison

Test case created by Montana Flynn

Preparation code

<script src="https://momentjs.com/downloads/moment.min.js"></script>
    

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Native Date
var timestamp = new Date(556095600000),
  day = timestamp.getUTCDate(),
  month = timestamp.getMonth() + 1,
  year = timestamp.getFullYear()

  var timeperiods = {
    "year": new Date(year).toISOString(),
    "month": new Date(year, month).toISOString(),
    "day": new Date(year, month, day).toISOString()
}
pending…
Moment.js
var momento = moment(556095600000),
  day = momento.date(),
  month = momento.month() + 1,
  year = momento.year()

  var timeperiods = {
    "year": moment(year, "YYYY").toISOString(),
    "month": moment(month + "-" + year, "MM-YYYY").toISOString(),
    "day": moment(day + "-" + month + "-" + year, "DD-MM-YYYY").toISOString()
}
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.

0 Comments