full dom vs multipple $.text

JavaScript performance comparison

Test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="aa">
<div id="a1">0</div>
<div id="a2">0</div>
<div id="a3">0</div>
<div id="a4">0</div>
<div id="a5">0</div>
<div>
 
<script>
Benchmark.prototype.setup = function() {
    var $aa = $('#aa');
    var aaHTML = $aa.html()
    var $a1 = $('#a1');
    var $a2 = $('#a2');
    var $a3 = $('#a3');
    var $a4 = $('#a4');
    var $a5 = $('#a5');
};
</script>

Preparation code output

0
0
0
0
0

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
$.text()
$a1.text(Math.random());
$a2.text(Math.random());
$a3.text(Math.random());
$a4.text(Math.random());
$a5.text(Math.random());
 
pending…
full dom
$aa.html(aaHTML);
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment