Closed
Bug 42309
Opened 24 years ago
Closed 23 years ago
Math.method()s run very slow [WAS: Math.sqrt() runs very slow]
Categories
(Core :: JavaScript Engine, defect, P3)
Core
JavaScript Engine
Tracking
()
VERIFIED
WORKSFORME
Future
People
(Reporter: kazhik, Assigned: waldemar)
References
()
Details
(Keywords: perf)
Attachments
(3 files)
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.
Reporter | ||
Comment 1•24 years ago
|
||
Reporter | ||
Comment 3•24 years ago
|
||
Another test case. http://www5a.biglobe.ne.jp/~terucco/bz/ants211/index.html This JavaScript does not use Math.sqrt(), but runs very slow.
Comment 4•24 years ago
|
||
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
Comment 5•24 years ago
|
||
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.
Comment 6•24 years ago
|
||
Comment 7•24 years ago
|
||
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.
Comment 8•24 years ago
|
||
Comment 9•24 years ago
|
||
I have discussed this with the engineers on the JavaScript Engine team. The reason for the performance problem may be due to the fact that JS 1.5 (used in Mozilla, but not in NN 4.x) uses a library called "libfdm" to do math operations. This is done to ensure accuracy across all platforms, but will of course be slower than utilizing native OS math processing. The team has asked me to send this one to Waldemar for his opinion -
Assignee: rogerl → waldemar
Updated•24 years ago
|
Status: NEW → ASSIGNED
Updated•24 years ago
|
Summary: Math.sqrt() runs very slow → Math.method()s run very slow [WAS: Math.sqrt() runs very slow]
Assignee | ||
Updated•24 years ago
|
Target Milestone: --- → Future
Comment 10•24 years ago
|
||
Mozilla became faster. This bug can be marked as worksforme. Math.sqrt() Moz: 451ms; IE: 171ms; NN4.7: 431ms
Comment 11•23 years ago
|
||
Per KOIKE's finding above, marking WORKSFORME -
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → WORKSFORME
Comment 12•23 years ago
|
||
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
Status: RESOLVED → VERIFIED
Comment hidden (spam) |
Comment hidden (spam) |
You need to log in
before you can comment on or make changes to this bug.
Description
•