dom tree vs collection
JavaScript performance comparison
Preparation code
<script src="//code.jquery.com/jquery-2.0.0b1.js"></script>
<div class="test" data-itemid="item_1">hello</div>
<div class="test" data-itemid="item_2">hello</div>
<div class="test" data-itemid="item_3">hello</div>
<div class="test" data-itemid="item_4">hello</div>
<script>
Benchmark.prototype.setup = function() {
var collection = [
{
model : {
id : 1,
attributes : {
height: "250px",
width : "400px",
itemid : "item_1"
}
}
},
{
model : {
id : 1,
attributes : {
height: "250px",
width : "400px",
itemid : "item_2"
}
}
},
{
model : {
id : 1,
attributes : {
height: "250px",
width : "400px",
itemid : "item_3"
}
}
},
{
model : {
id : 1,
attributes : {
height: "250px",
width : "400px",
itemid : "item_4"
}
}
}
];
};
</script>
Preparation code output
hello
hello
hello
hello
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
dom tree |
|
pending… |
collection |
|
pending… |
dom tree with last() |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments