new Image vs cloneNode

JavaScript performance comparison

Test case created

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
new Image
var n = 100, arr = [];
while( --n >= 0 ){
    arr[n] = new Image();
}
pending…
cloneNode
var n = 100, arr = [];
arr[0] = new Image();
while( n = n - 1 ){
    arr[n] = arr[0].cloneNode();
}
pending…
new Image Attribs
var n = 100, arr = [];
while( --n >= 0 ){
    arr[n] = new Image();
    arr[n].setAttribute('alt','');
    arr[n].setAttribute('border','0');
}
pending…
cloneNode Attribs
var n = 100, arr = [];
arr[0] = new Image();
arr[0].setAttribute('alt','');
arr[0].setAttribute('border','0');
while( n = n - 1 ){
    arr[n] = arr[0].cloneNode();
}
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