简体   繁体   English

IE9 Javascript比IE8慢-太奇怪了!

[英]IE9 Javascript slower than IE8 - that's weird!

I'm having difficulty in explaining why the following code runs slower in IE9 than IE8! 我很难解释为什么以下代码在IE9中比IE8

Here's some test code that runs smoothly in about half a second in (latest) FF/Chrome/Safari on OS X, WinXP, and Win7 plus IE7 & 8 on WinXP (for simplicity I removed the tweak that makes it work in IE6). 这是一些测试代码,它们可以在OS X,WinXP和Win7上的(最新)FF / Chrome / Safari和WinXP 上的 IE7和8上的(最新)FF / Chrome / Safari中平稳运行约半秒钟(为简单起见,我删除了使其在IE6中运行的调整)。

For some reason I can't explain, it's awful in IE9, slow and clunky. 由于某种原因,我无法解释,它在IE9中很糟糕,缓慢又笨拙。 Reducing the time for the setTimeout makes it a bit quicker but no less jerky. 减少setTimeout的时间可以使其更快一些,但也不会那么生涩。

I've tried removing and benchmarking a number of what might be the choke points (Math.min for example ... all with no change. 我尝试删除一些基准点并对其进行基准测试(例如,Math.min ...全部不变)。

I'm stumped ... can anyone please point me in the right direction?... preferably one that does not require browser-sniffing? 我感到难过...任何人都可以向我指出正确的方向吗?...最好是不需要浏览器嗅探的人?

Here's the test code ... 这是测试代码...

<div id = 'panel' class='noShow' style='background-color: #aaa;'>
    <div id = 'wrapper' class='slideWrapper'>
        <p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p>
    </div>
</div>


<script type = 'text/javaScript'>

    var e = document.getElementById('panel');
    var w = document.getElementById('wrapper');

    w.style.overflow = 'hidden';                                                
    w.style.height = '1px'; 
    var sh = w.scrollHeight;
    show();
    function show()
    {
        setTimeout(function()
           {
                w.style.height = Math.min(sh, (w.offsetHeight + Math.ceil(sh/15))) + 'px';  
                if(
                     (w.offsetHeight < sh)
                ) 
                {
                    show(e);
                }
                else 
                {
                    w.style.height = 'auto'; 
                }                       
        }, 20); 
    }   
</script>

IE9默认在VMware Virtual Machines上进行软件渲染(截至2011年7月8日),应该会在不久的将来发布此修补程序,但此博客文章未提供时间表。

There are always odd performance variations when running in a virtualized environment. 在虚拟环境中运行时,性能总是会有奇怪的变化。 The selection of drivers and how the software offloads the processing will have an impact. 驱动程序的选择以及软件如何减轻处理负担将产生影响。 Have you tried updating the drivers on your system? 您是否尝试过更新系统上的驱动程序?

Are you running the 64 bit version of IE 9 or the 32 bit version? 您正在运行IE 9的64位版本还是32位版本? The 64 bit version is not running Chakra which is the optimized JavaScript engine from the 32 bit version 64位版本未运行Chakra,这是32位版本中经过优化的JavaScript引擎

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM