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
Given, two different ways of storing elements in a list:
["a", "b"]
{"a": true, "b": true}
Finding a specific item in an array:
When using objects as demonstrated above, we can simply use the item-accessor (test 3)
The Javascript engine has to traverse the scope chain in the object-case. Therefore I assumed similar results for tests 2 and 3.
Test 4-6 search for random items, in order to prevent browsers from returning cached results.
<script src="http://jshashtable.googlecode.com/svn-history/r20/trunk/hashtable.js"></script>
<script>
var MAX_LENGTH = 9999;
var u = {};
var v = [];
var w = new Hashtable();
function item() {
return parseInt(MAX_LENGTH / 2) * 1.3;
};
function randItem() {
return parseInt(Math.random() * MAX_LENGTH) * 1.3;
}
for (var i = 0; i < MAX_LENGTH; ++i) {
u[i * 1.3] = true;
v.push(i * 1.3);
w.put(i * 1.3, true);
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
array: for-loop |
| ready |
array: indexOf |
| ready |
object: accessor |
| ready |
array: for-loop (random item) |
| ready |
array: indexOf (random item) |
| ready |
object: accessor (random item) |
| ready |
jsHashtable (random item) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.