开发者

Why is IE 9 so slow at this DOM benchmark? [closed]

开发者 https://www.devze.com 2023-04-13 07:51 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so tha开发者_Python百科t it can be reopened, visit the help center. Closed 11 years ago.

Link to test: http://nontroppo.org/timer/Hixie_DOM.html

Why is IE 9 so slow at this DOM benchmark? [closed]


The biggest issue I saw was the index testIndex function which in your screenshot takes just over 8 seconds in IE9. Which is copied below for reference.

function testIndex(div) {
    for (var i = 0; i < count; i += 1) {
        divs[i] = div.childNodes[count*2 - i*2 - 1];
    }
}

Note that divs is an array with 10000 indexes.

There are quiet a few things going on in this function and I think the slow down happens because browsers other than IE have optimized these types of DOM manipulations and calculation caching. I think part of the problem is that this function, unlike all the others, adds a copy of what it finds to the divs array. So it crawls the DOM, copies the object it finds to an array. IE has never been terribly fast when crawling the DOM. Try the following and see what the difference is.

function testIndex(div) {
    var doublecount = (count*2) -1;
    for (var i = 0; i < count; i += 1) {
        div.childNodes[doublecount - i*2];
    }
}

That may speed things up.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号