Date.now vs new Date().getTime() vs +new Date (v43)

Revision 43 of this benchmark created by VeganBen on


Preparation HTML

<script>
if (!('now' in Date)) {
 Date.now = function() { return new Date().getTime();}
}
Date.now2 = function() { return +(new Date);}
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Date.now()
Date.now()
ready
new Date().getTime()
new Date().getTime()
ready
+new Date
+new Date
ready
parentheses 1
(new Date).getTime()
ready
parentheses 2
(new Date()).getTime()
ready
valueof
new Date().valueOf()
ready
+(new Date) shim
Date.now2();
ready
valueof parentheses
(new Date).valueOf()
ready
Number Primitive
Number(new Date())
ready
Date Parse
Date.parse(new Date())
ready
multiply co-erce
1* (new Date());
ready
window.performance
window.performance.now()
ready

Revisions

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