Math.sqrt() seems to run very slow. See the sample page. http://www5a.biglobe.ne.jp/~terucco/bz/xeyes.html The eyeballs doesn't move when I accessed this page by old PC (Pentium 166Mhz). The following attachment shows Math.sqrt() causes a problem.
setting status to New
Here are some timing results using the attachment above. Using a Mozilla tip build 06/27/2000 on WinNT. Attachment = http://bugzilla.mozilla.org/showattachment.cgi?attach_id=10021 All times in milliseconds. The test loops have 50000 iterations. loop that is empty loop of Math.sqrt(2) IE4 31 187 NN4.7 62 421 Moz 78 9812
I've found that Math.pow() is _very_ slow compared to Navigator 4.73 and IE5.01, so maybe it's the Math() object in general and not simply Math.sqrt()? I'll upload a simple testcase which squares a number 'd'. d's a small number (122), the number of iterations is 100,000, which should take around 130ms in Mozilla. Still, the job takes ~8000ms to complete using Math.pow(), 220ms using d*d. in comparison IE5.01 uses ~550ms with Math.pow(), ~170ms using d*d, and NN4.73 ~1800ms with Math.pow(), ~220ms with d*d. I'll do some more testing with the various other Math() methods and see what I find.
Ack, forgot to mention that I'm running build 2000070508, Windows 98 first edition. Also added myself to the Cc:-list. Made a quick test using Math.abs(), and the result is the same as for Math.sqrt() and Math.pow(). This time I used Math.abs() for one loop and '(x < 0) ? -x : x' in the other. The loop with Math.abs() takes ~8000ms compared to ~220ms for the other. Speed for the two others is just about the same: ~1700ms & ~220ms for NN4.73, and ~500ms & ~160ms for IE5.01. Will upload the Math.abs() testcase too.
Mozilla became faster. This bug can be marked as worksforme. Math.sqrt() Moz: 451ms; IE: 171ms; NN4.7: 431ms
Per KOIKE's finding above, marking WORKSFORME -
VERIFIED WORKSFORME using nightly binaries 20010312xx on WinNT, Linux, and Mac. These are the timings I got from the testcase at attachment 10021 [details] above. In each case Mozilla is running an empty loop, then a loop of Math.sqrt(2). WINNT LINUX MAC Empty loop: 47ms 45ms 31ms Loop of Math.sqrt(2): 391ms 480ms 370ms These are much better than the results from 2000-06-28 17:17 above: Empty loop: 78ms Loop of Math.sqrt(2): 9812ms