Date.now() vs new Date() vs performance.now() (v11)

Revision 11 of this benchmark created by dan on


Description

Do try to cache new Date()!!! Do try to use high precsision performance timing API!!! Any suggestions, gentlemen, ;P ???? What can we cache? Do I really have to use loops here?

Test runner

Ready to run.

Testing in
TestOps/sec
+new Date
var i = 0;

while (i++ < 100000) {
    +new Date;
}
ready
cached (new Date())
var i = 0;
var cachedDate = new Date();

while (i++ < 100000) {
    cachedDate.getTime();
}
ready
(new Date).getTime()
var i = 0;

while (i++ < 100000) {
    (new Date).getTime();
}
ready
new Date/1
var i = 0;

while (i++ < 100000) {
    new Date/1;
}
ready
cached.valueOf()
var i = 0;
var cachedDate = new Date();

while (i++ < 100000) {
    cachedDate.valueOf();
}
ready
performance.now()
var i = 0;

while (i++ < 100000) {
    performance.now();
}
ready
Date.now()
var i = 0;

while (i++ < 100000) {
    Date.now();
}
ready

Revisions

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