Compare dates (v4)

Revision 4 of this benchmark created on


Setup

var a = new Date(2013, 11, 12, 1, 2, 3);
var b = new Date(2013, 11, 12, 1, 2, 3);

Test runner

Ready to run.

Testing in
TestOps/sec
plus trick
var equal = +a === +b;
ready
getTime
var equal = a.getTime() === b.getTime();
ready
Subtract
var equal = (a - b) === 0;
ready
Compare with <= and >=
var equal = a <= b && a >= b;
ready
Compare with < and >
var equal = !(a < b || a > b);
ready
Single < comparison (not checking for equality)
var lt = a < b;
ready
< with getTime (not checking for equality)
var lt = a.getTime() < b.getTime();
ready

Revisions

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