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
I was wondering: “What’s the performance overhead of using [].prototype
instead of Array.prototype
while converting object into array?”.
It seems logic that Array.prototype
will be more performant than [].prototype
because [].prototype
will instantiate an Array
on every call.
In fact, the results are very similar and close for Firefox/Safari/Webkit. But Chrome is way more efficient with Array.prototype
.
<script>
unshift.apply({}, 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'.split(' '));
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Array.protoype |
| ready |
[].prototype |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.