object vs array of object
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var list1 = {
"AAPL": "Apple Inc.",
"GOOG": "Google Inc.",
"INTC": "Intel Corporation"
};
var list2 = [{
"ticker": "AAPL",
"name": "Apple Inc."
}, {
"ticker": "GOOG",
"name": "Google Inc."
}, {
"ticker": "INTC",
"name": "Intel Corporation"
}];
function go(element) {
var data = {
'ticker': element.ticker,
'name': element.name,
};
console.log(data);
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
list1 |
|
pending… |
list2 |
|
pending… |
list2 for loop |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments