Moment string to int

JavaScript performance comparison

Test case created by Jason Mulligan

Info

Testing how slow moment.js is for converting a string to an epoch, vs a float.

Preparation code

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

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Float to epoch
var arg    = 1365518691.309,
    result = new Date(moment(arg * 1000).format("YYYY/MM/DD HH:MM:00")).getTime() / 1000;
pending…
String to epoch
var arg    = "1365518691.309",
    result = new Date(moment(arg * 1000).format("YYYY/MM/DD HH:MM:00")).getTime() / 1000;
pending…
UTC String to epoch
var arg    = "Tue, 09 Apr 2013 14:52:28 GMT",
    result = new Date(moment(arg).format("YYYY/MM/DD HH:MM:00")).getTime() / 1000;
pending…
Float to epoch with unix()
var arg    = 1365518691.309,
    result = new Date(moment.unix(arg).format("YYYY/MM/DD HH:MM:00")).getTime() / 1000;
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