date.now() vs new Date() (v8)

Revision 8 of this benchmark created by Goktug on


Setup

var nowFn = Date.now ? Date.now : function() {
        return (new Date()).getTime();
      };

Test runner

Ready to run.

Testing in
TestOps/sec
new Date()
return new Date().getTime();
ready
Date.now()
if (Date.now) {
  return Date.now();
}
return (new Date()).getTime();
ready
alias
return nowFn();
ready

Revisions

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