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
encode = function(str) {
try {
str = str.replace(/'/g, '"');
str = str.replace(/\[\s*"([^"]+)"\s*\]/g, '.$1'); // object['property'] -> object.property
var list = [], match, merge=false, totalchars, i, t, elementproperty,
prepare_array = function (){
totalchars += arguments[0].length;
if (arguments[4] === 0 && (typeof arguments[1] === 'undefined' || arguments[1] === ''))
return 0;
if (typeof list[i] === 'string')
list[i] = [];
if (typeof arguments[2] === 'string' && arguments[2] !== '')
list[i].push(Number(arguments[2]));
else if (typeof arguments[3] === 'string' && arguments[3] !== '')
list[i].push( eval('['+arguments[3]+']') );
else
list[i].push( arguments[1] );
return 1;
};
// Spliting dots
// "From.this.example" -> ["From", "this". "example"]
str.replace(/([^.]+)/g, function(){
match = arguments[1];
if (merge) {
merge = false;
list[list.length-1] += '.' + match;
match = list[list.length-1];
}
else
list.push(match);
if ((match.match(/\(/g) || []).length !== (match.match(/\)/g) || []).length)
merge = true;
});
for (i=0, t=list.length; i<t; ++i) {
totalchars = 0;
elementproperty = list[i];
if (list[i].replace(/(^[A-Za-z_$][\w_$]*)|(?:\[\s*(\d+)\s*\])|(?:\((.*)\))/g, prepare_array).indexOf('0') > -1 ||
elementproperty.length !== totalchars)
return false;
}
return list;
}
catch(e) {
return false;
}
};
Ready to run.
Test | Ops/sec | |
---|---|---|
simple |
| ready |
complex |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.