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
var a = ['vegan','soccer','baby-shop','cycling-and-triathlon','sporting-goods','girls-shoes','mens-jeans','pajamas','socks'];
var o = {'vegan':0,'soccer':1,'baby-shop':2,'cycling-and-triathlon':3,'sporting-goods':4,'girls-shoes':5,'mens-jeans':6,'pajamas':7,'socks':8};
//improved performance if array is sorted by most common requests
function index_a(x)
{var i=a.length;while(--i>-1)if(a[i]==x)return i;return -1;}
function index_o(x)
{if(o[x]) return o[x]; return -1;}
function index_switch(x)
{switch(x){case 'vegan':return 0;case 'soccer':return 1;case 'baby-shop':return 2;case 'cycling-and-triathlon':return 3;case 'sporting-goods':return 4;case 'girls-shoes':return 5;case 'mens-jeans':return 6;case 'pajamas':return 7;case 'socks':return 8;default:return -1;}}
Ready to run.
Test | Ops/sec | |
---|---|---|
loop |
| ready |
lookup |
| ready |
switch |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.