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 types of sets in JS - which one is the fastest?
Tests whether Object.hasOwnProperty
, Object in
operator, Object[property]
, Set.has
, Array.includes
or Array.indexOf() > -1
is fastest.
const set = new Set();
const object = {};
const nullObject = Object.create(null);
const array = new Array();
Ready to run.
Test | Ops/sec | |
---|---|---|
Add items to normal object |
| ready |
Add items to null object |
| ready |
Add items to Set |
| ready |
Add items to array |
| ready |
Check if item in null object (property method) |
| ready |
Check if item in normal object (property method) |
| ready |
Check if item in null object (in operator) |
| ready |
Check if item in normal object (in operator) |
| ready |
Check if item in null object (hasOwnProperty on prototype) |
| ready |
Check if item in normal object (hasOwnProperty on prototype) |
| ready |
Check if item in normal object (hasOwnProperty on instance) |
| ready |
Check if item in Set |
| ready |
Check if item in array (Array.includes) |
| ready |
Check if item in array (Array.indexOf) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.