Date equality comparison

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var from = new Date(1900, 0, 1).getTime();
    var to = new Date(2100, 0, 1).getTime();
    function getRandomDate() {
        return new Date(from + Math.random() * (to - from));
    }
   
    var d1 = getRandomDate()
    var d2 = getRandomDate()
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
d1.getTime() === d2.getTime()
d1.getTime() === d2.getTime()
pending…
+date
+d1 === +d2
pending…
d1 - d2
d1 - d2
pending…
Number(d1) === Number(d2)
Number(d1) === Number(d2)
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment