Closed rwaldron closed 9 years ago
Great Feedback, just to add some perftest http://jsperf.com/new-date3e3e421312, I will push for this change
Micro benchmarks are an anti-pattern. Especially ones that compare apples vs. oranges. new Date()
alone doesn't return the same thing as the other 3 and the valueOf/getTime will short-circuit to the same internal operation (notice they measure almost identically). Date.now()
is always going to be faster because it doesn't require the initialization/allocation of a complete Date object, where the others do.
Changes were applied and merged to development.
This one is interesting, not only is a duplication of the built-in function
Date.now()
, it also callsMath.round
on a number that's already an integer, ie. the return value ofnew Date().getTime()
. Incidentally,Date.now()
is just a fasternew Date().getTime()
.