+new Date vs Date.now() vs performance.now() (v25)

Revision 25 of this benchmark created on


Description

https://twitter.com/jaffathecake/status/306706682552143872

jaffathecake: Avoid "+new Date" to generate timestamps during animation. Use "Date.now()" or "performance.now()" instead http://t.co/Hle0qzxWeZ

Setup

var perf = performance;
    var pnow = perf.now;
    var dnow = Date.now;
    var round = Math.round;
    var getp = function () {return perf.now()};
    var getpr = function () {return Math.round(perf.now())};
    var getprc = function () {return round(perf.now())};
    var getpc = function () {return pnow()};
    var getdc = function () {return dnow()};
    var getd = function () {return Date.now()};

Test runner

Ready to run.

Testing in
TestOps/sec
Date.now
getp()
ready
+new Date()
getpc()
ready
performance.now()
getd()
ready
new Date().getTime()
getpr()
ready
new Date().valueOf()
getprc()
ready
Cached performance object
getdc()
ready

Revisions

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