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
function demoStructure(someNumber) {
this.someNumber = someNumber;
this.someIncrementation = someNumber + 10;
this.someTrashData = {
"1" : someNumber +1,
"2" : someNumber +2,
"3" : someNumber +3,
"4" : someNumber +4,
"5" : someNumber +5,
"6" : someNumber +6,
};
}
demoStructure.prototype.doSomething = function() {
this.someIncrementation++;
}
demoStructure.prototype.recurse = function() {
this.doSomething();
if(this.someNumber == 0) return;
var next = dataSource[(this.someNumber - 1)];
next.recurse();
}
var testCount = 10000;
var indexLimit = testCount-1;
var dataSource = [];
for (var i = 0; i < testCount; i++) {
dataSource.push(new demoStructure(i));
}
function incrementIterative(limit) {
for (var i = 0; i < limit; i++) {
var cur = dataSource[i];
cur.doSomething();
}
}
function incrementRecursive(index) {
if (index < 0)
return;
var cur = dataSource[index];
cur.doSomething();
incrementRecursive(--index);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Iterative 1000 |
| ready |
Recursive 1000 |
| ready |
Iterative 100 |
| ready |
Recursive 100 |
| ready |
Inner Recurse 100 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.