jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Different ways of creating a valueOf()
of a Date
object.
Findings: in Opera 10.60, Chrome 5.0.375.125, Safari 5.0.1 (6533.17.8) and Firefox 3.6.8, Date.now()
is the fastest. It’s more than 50% faster than +new Date()
. Too bad IE8 and below don’t support it.
Certainty, dereferenced var datenow = Date.now
is more faster than Date.now
.
<script>
// IE8 and below don’t support ES5 Date.now()
!Date.now && (Date.now = function() {
return new Date().valueOf();
});
var datenow = Date.now;
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Using .valueOf() |
| ready |
Using .getTime() |
| ready |
Using +new Date() |
| ready |
Using +new Date |
| ready |
Date.now() |
| ready |
Date.now() dereferenced |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.