What methods can I use to reproduce a sporadic IE "A script on this page is causing Internet Explorer to run slowly" notification?
I'm trying to replicate a bug which the client has reported, it's the "this script is running slow" notification which appears in IE due to it's extremely slow JS/DOM parsing.
This doesn开发者_StackOverflow社区't occur on my virtualbox IE6 ( client has IE6 ) nor does it work on a test machine I have ( some mac mini ).
I can guarantee that there's a lot of JS happening though, and there's lots of HTML being processed after being retrieved using XHR, in addition a lot of JS operating on the appended DOM elements after that. I can't possibly post the entire script, but I'm confident I could easily track the issue down but I want to reproduce this to play around with optimizing it.
This is a really high profile client so I can't just get on the phone or IM and speak to them. Are there any ways I could slow down my machine in order to reproduce this bug? Or should I just stick to asking for the client's computer specifications and try to get access to an older computer which would have a more likely chance of reproducing the issue? Or even use something like browsercam?
Another idea I thought about would be sort of, making the JS operate even more, in order so I do get the issue and try to optimize my code so even with my additional code it won't post the script notification error.
I'd appreciate any advice.
run inside a VM, and lower the memory on purpose to have excess swapping. If this still doesn't work, you can run some benchmarking SW in the background, those tends to chew a lot of CPU.
There are a lot of things that can be done to slow down your computer. The real issue here is whether you want it to be precise, or just something that chews up enough CPU cycle to enable IE6 to reproduce this issue more frequently.
Starting with the rough and simple methods: Using the Virtual Machine, give it only one CPU, then run something with high CPU usage, like playing a movie. Try to use something that does not use up too much RAM, because forcing IE into the pagefile won't help you here. To get more precise slowing, you might want to underclock your CPU, although doing this for the sake of debugging Javascript is a little extreme. Getting access to an old computer may also do the trick, although none of these are guaranteed to reproduce the problem.
Using screen sharing software may also be difficult - it depends on how willing the client is to installing and setting up software like that, but this should definitely help reproduce the bug. To have to play around with it while you use up the client's computer's time though will probably be unacceptable.
There are other things you can try, in addition to slowing down the computer. You can actually manually lower the time limit for the IE slow script warning, according to this Microsoft support article, by changing some registry values. Try deep profiling the Javascript on your own machine, even if you cannot generate the slow script error, you can still find bottlenecks or places where the script performs badly.
I found your problem:
This is a really high profile client so I can't just get on the phone or IM and speak to them.
- this is something that you're going to want to fix, if they want it fixed.
Otherwise, if you have some idea of the problem, you could:
- create a XML/HTML document using random information and store it in a string
- then try and parse that using XMLDom or something
You should try doing it with a million rows:
sXML = "<?xml version="1.0" encoding="UTF-8"?>\n<rootElement>\n";
for (var i=0;i<1000000;i++){
sXML += '<element name="' + Math.floor(Math.random()*10001) + '">'
+ 'some more random text: ' + Math.floor(Math.random()*1001)
+ "</element>\n";
}
sXML = "</rootElement>";
var oXML = (new DOMParser()).parseFromString(sXML, "text/xml");
var root = oXML.documentElement;
Of course you can make it as elaborate as you want, using random elements, etc.
精彩评论