Object lookup in Array
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var array = [], countDuplicates = 0;
function getRandom(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function populateArray() {
for (var i = 0; i < 1000000; i++) {
array.push({
name: "name_" + i,
size: getRandom(100, 1000)
});
}
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Lookup by name |
|
pending… |
Lookup by name and size |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments