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
(edited to make the string key actually contain a string portion--otherwise it was treating it as a number)
var mapStr = new Map();
var objStr = {};
var mapNum = new Map();
var objNum = {};
var strKeys = [];
var numKeys = [];
for (let i=0; i<10000 ; i++) {
mapStr.set(`key_${i}`, Math.random());
objStr[`key_${i}`] = Math.random();
mapNum.set(i, Math.random());
objNum[i] = Math.random();
numKeys[i] = i;
strKeys[i] = `key_${i}`;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
[Number key] map.get |
| ready |
[String key] map.get |
| ready |
[Number key] obj[key] |
| ready |
[String key] obj[key] |
| ready |
[known str key] map.get |
| ready |
[known str key] obj[key] |
| ready |
[lookup num key to compare with known str key] obj[key] |
| ready |
string literal key |
| ready |
numeric literal key |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.