Difference between revisions of "Talk:Abs"

From the Fallout3 GECK Wiki
Jump to navigation Jump to search
imported>Haama
(Please check it)
 
imported>DragoonWraith
 
(One intermediate revision by one other user not shown)
Line 2: Line 2:
While I have my doubts too, this wouldn't be hard to test and was added by a dev. Please check it - maybe have 100 of them going in a frame and see if it decreases the FPS.
While I have my doubts too, this wouldn't be hard to test and was added by a dev. Please check it - maybe have 100 of them going in a frame and see if it decreases the FPS.
<br>--[[User:Haama|Haama]] 16:03, 20 December 2008 (UTC)
<br>--[[User:Haama|Haama]] 16:03, 20 December 2008 (UTC)
:It's literally impossible.  abs is just switching the sign if it's negative, and works exactly no slower than:
<pre>if num < 0
    set num to 0 - num
endif</pre>
:And as we both no doubt have done, the game will not slow down if you do ''more complicated'' snippet 500 times in a frame.
:In C you can just do abs(num) because it's a predefined function and every CPU is engineered to do that op (among others) ridiculously fast (check your Ghz and multiply that by ~1 billion times per second).
:Clearly they just copied the same template for all the new math functions and switched the function names in each.  It applies for all of the new math functions ''except'' abs.
:--[[User:Quetzilla|Quetzilla]] 19:13, 20 December 2008 (UTC)
::A better question is, "Why did they use slow implementations of these functions?" There are ridiculously fast algorithms publicly available for all of those operations.
::[[User:DragoonWraith|DragoonWraith]] &middot; [[User talk:DragoonWraith|talk]] &middot; 20:36, 20 December 2008 (UTC)

Latest revision as of 15:36, 20 December 2008

Sin, cos, tan, pow, log, and abs (particularly pow and log) are extremely slow. Do not use them in script blocks that get executed every frame.

While I have my doubts too, this wouldn't be hard to test and was added by a dev. Please check it - maybe have 100 of them going in a frame and see if it decreases the FPS.
--Haama 16:03, 20 December 2008 (UTC)

It's literally impossible. abs is just switching the sign if it's negative, and works exactly no slower than:
if num < 0
     set num to 0 - num
endif
And as we both no doubt have done, the game will not slow down if you do more complicated snippet 500 times in a frame.
In C you can just do abs(num) because it's a predefined function and every CPU is engineered to do that op (among others) ridiculously fast (check your Ghz and multiply that by ~1 billion times per second).
Clearly they just copied the same template for all the new math functions and switched the function names in each. It applies for all of the new math functions except abs.
--Quetzilla 19:13, 20 December 2008 (UTC)
A better question is, "Why did they use slow implementations of these functions?" There are ridiculously fast algorithms publicly available for all of those operations.
DragoonWraith · talk · 20:36, 20 December 2008 (UTC)