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
More details at my blog : http://pic-o.com/blog/2011/11/native-linked-list-hack-vs-array
Javascript lacked native linkedlist support, and for an interpretive language, rebuilding the engine, is a costly alternative, marginalizing the benefits.
Or so we thought... hidden within the DOM specification, are linked lists. The ability to rapidly manipulate nested children of DOM structures in the modern browsers, is in part attributed to linked lists. Hence why not exploit it for data instead of dom objects. or perhaps both?
<script src="//pic-o.com/wp-content/uploads/2011/12/jsCompatible.js">
</script>
<script src="//pic-o.com/wp-content/uploads/2011/12/jsClass.js">
</script>
<script src="//pic-o.com/wp-content/uploads/2011/12/divLinkedList.js">
</script>
//Base variable creation testing
var read;
var zero = 0;
var blankObj = {};
var blankArr = [];
var blankDLL = new(divLinkedList)();
//Population limit for pre generated content
var populateLimit = 1000;
var populateMid = populateLimit / 2;
var populateNext = populateLimit + 1;
var count = 0;
var countMid = populateMid;
var countNext = populateNext;
var objPopLimit = 'p' + populateLimit;
var objPopMid = 'p' + populateMid;
var objPopNext = 'p' + populateNext;
var objPopZero = 'p' + zero;
//Premade content testing
var testObj = {};
for (var a = 0; a <= populateLimit; a++) {
testObj['p' + a] = a;
}
var testArr = [];
for (var a = 0; a <= populateLimit; a++) {
testArr[a] = ('p' + a);
}
var testDLL = new(divLinkedList)();
for (var a = 0; a <= populateLimit; a++) {
testDLL.push('p' + a);
}
if( !window.testDump ) {
window.testDump = [];
}
if( Math.random() >= 0.9999 ) {
window.testDump.push( [
blankObj['p'+Math.round(Math.random()*1000)],
(blankArr.length > 0)?( blankArr[ Math.round(Math.random()*( blankArr.length-1 )) ] ) : 0,
(blankDLL.length > 0)?( blankDLL.gets( Math.round(Math.random()*( blankArr.length-1 )) ) ) : 0,
testObj['p'+Math.round(Math.random()*1000)],
(testArr.length > 0)?( testArr[ Math.round(Math.random()*( testArr.length-1 )) ] ) : 0,
(testDLL.length > 0)?( testDLL.gets( Math.round(Math.random()*( testDLL.length-1 )) ) ) : 0
] );
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Obj Create |
| ready |
Obj (blank) Property Adds |
| ready |
Obj (filled) Property Adds |
| ready |
Obj Delete Starts |
| ready |
Obj Null Starts |
| ready |
Obj Delete Mids |
| ready |
Obj Null Mids |
| ready |
Obj Delete Ends |
| ready |
Obj Null Ends |
| ready |
Obj Read start |
| ready |
Obj Read Mid |
| ready |
Obj Read End |
| ready |
Obj Write Start |
| ready |
Obj Write Mid |
| ready |
Obj Write End |
| ready |
Array Create |
| ready |
Array (blank) Property Add |
| ready |
Array (filled) Property Add |
| ready |
Array (blank) .push |
| ready |
Array (filled) .push |
| ready |
Array (filled) .pop |
| ready |
Array (filled) .shift |
| ready |
Array (filled) .unshift |
| ready |
Array (blank) .unshift |
| ready |
Array (filled) .slice(start, mid) |
| ready |
Array (filled) .slice(mid, [end]) |
| ready |
Array (filled) .slice(mid, end) |
| ready |
Array (filled) .slice(mid, end) |
| ready |
Array Delete Start |
| ready |
Array Null Start |
| ready |
Array Delete Mid |
| ready |
Array Null Mid |
| ready |
Array Delete End |
| ready |
Array Null End |
| ready |
Array Read Start |
| ready |
Array Read Mid |
| ready |
Array Read End |
| ready |
Array Write Start |
| ready |
Array Write Mid |
| ready |
Array Write End |
| ready |
Array Splice Mid Insert |
| ready |
Array Splice Mid Remove |
| ready |
divLinkedList Create |
| ready |
divLinkedList Adding (blank) .sets(0, data) |
| ready |
divLinkedList Adding (filled) .sets(populateNext, data) |
| ready |
divLinkedList (blank).push |
| ready |
divLinkedList (filled).push |
| ready |
divLinkedList (filled).pop |
| ready |
divLinkedList (filled).shift |
| ready |
divLinkedList (filled).unshift |
| ready |
divLinkedList (blank).unshift |
| ready |
divLinkedList Null Start |
| ready |
divLinkedList Null Mid |
| ready |
divLinkedList Null End |
| ready |
divLinkedList Null post-start |
| ready |
divLinkedList Null pre-End |
| ready |
divLinkedList Read Start |
| ready |
divLinkedList Read Mid |
| ready |
divLinkedList Read End |
| ready |
divLinkedList Read post-Start |
| ready |
divLinkedList Read pre-End |
| ready |
divLinkedList Null Mid |
| ready |
divLinkedList Write Mid |
| ready |
divLinkedList Splice Mid Insert |
| ready |
divLinkedList Splice Mid Remove |
| ready |
Array splice removal |
| ready |
Array splice removal add |
| ready |
Array splice beginning |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.