Closed Bug 82706 Opened 25 years ago Closed 25 years ago

Bad performance of JavaScript Engine, especially when manipulating the DOM

Categories

(Core :: JavaScript Engine, defect)

x86
Other
defect
Not set
normal

Tracking

()

VERIFIED DUPLICATE of bug 40988

People

(Reporter: Erich.Iseli, Assigned: rogerl)

Details

(Keywords: perf)

I ran a few tests: 1) increment a variable 1 million times 2) createElement 10,000 times 3) appendChild 10,000 times Based on these, I was surprized to see that already in test 1, Mozilla is 3.5 times slower than IE. In Test 2, this number increased to 5.5 times slower. But when I performed test 3, I just couldn't believe it: I first thought the browser was frozed when after 28 seconds, the browser responded again... IE does the same task in 1 second. So here (very complicated math...) we are 28 times slower than IE. Of course I know you never really do such things, you create 10, 20 elements, and then everything happens quite fast. But the fact is, Mozilla is slower. This is not a rant, so please don't flame me. I didn't find another similar bug report, but I don't exclude the possibility this one is a dupe.
I wanted to post the script as Attachment, but due to some firewall restrictions in my company, it didn't get through, so here it is: <html> <head> <title>Test</title> <script type="text/javascript"> function init() { myHome = document.getElementById("home"); var first = new Date(); var start = first.getMilliseconds()+(first.getSeconds()*1000)+(first.getMinutes ()*60000); for (i=0;i<10000;i++) { newDiv = document.createElement("div"); myHome.appendChild(newDiv); } var last = new Date(); var end = last.getMilliseconds()+(last.getSeconds()*1000)+(last.getMinutes() *60000); alert("It took "+(end-start)/1000+" seconds to create 10,000 divs."); } </script> </head> <body id="home" onload="init()"> </body> </html>
To show you that this is not only a benchmark thing, but can also be noticed on some web sites: try the JavaScript menu on http://www.arcor.net with IE and Mozilla. Notice how slow it is with Moz compared to IE.
*** This bug has been marked as a duplicate of 40988 ***
Status: NEW → RESOLVED
Closed: 25 years ago
Keywords: perf
Resolution: --- → DUPLICATE
Marking Verified Duplicate. FWIW, here are timings I got from "1) increment a variable 1 million times". Actually, the following HTML allows you to choose the number of iterations yourself: <html> <head> <title>Bug 82706</title> <script type="text/javascript"> function init() { var UBound = prompt("How many iterations would you like to run?"); var start = new Date(); for (i=0; i<UBound; i++) { } var duration = new Date() - start; alert(duration + " ms"); } </script> </head> <body onload="init();"> <P><B>Testing how long it takes to increment a variable in JavaScript -</B> </body> </html> RESULTS (in milliseconds). Using Mozilla binary 2001052206 on WinNT: 10^3 10^4 10^5 10^6 IE4.7 0-16 32 266 2656 NN4.7 63 640 6300 62860 Mozilla 0-16 109 1078 10875 So on this pure JavaScript, Mozilla seems about 4 times slower than IE4.7, but 6 times faster than NN4.7.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.