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.
<script>
// IE8 and below don’t support ES5 Date.now()
if (!Date.now) {
Date.now = function() {
return +new Date();
};
};
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Using .valueOf() |
| ready |
Using .getTime() |
| ready |
+new Date() |
| ready |
+new Date |
| ready |
Date.now() |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.