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 outVar = 1.0;
var count = 4096;
var counter = 0;
function TestFunc(i) {
outVar += i;
}
function Trans(v) {
return Math.floor(Math.random() * count);
}
function GetNext() {
return (counter++) & 511;
}
var switchFunc = eval((function() {
var str = "(function(i){switch(i){";
for(var i = 0; i < count; i++) {
str += "case " + i + ": TestFunc(" + Trans(i) + "); break; ";
}
str += "}})";
return str;
})());
var ifFunc = eval((function() {
var str = "(function(i){";
for(var i = 0; i < count; i++) {
str += "if(i == " + i + ") { TestFunc(" + Trans(i) + "); return;} ";
}
str += "})";
return str;
})());
var arrayMap = [];
for(var i = 0; i < count; i++) {
arrayMap.push((function(i) {
return function() { TestFunc(i); };
})(Trans(i)));
}
var dictionaryMap = {};
for(var i = 0; i < count; i++) {
dictionaryMap[String(i)] = (function(i) {
return function() { TestFunc(i); };
})(Trans(i));
}
Ready to run.
Test | Ops/sec | |
---|---|---|
switch |
| ready |
if |
| ready |
array |
| ready |
dictionary |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.