Difference between revisions of "Script Comparison Tests"
imported>Haama (Created) |
imported>Haama (Category link) |
||
Line 38: | Line 38: | ||
<pre>if (Object1.GetParentCell == SomeCell)</pre> | <pre>if (Object1.GetParentCell == SomeCell)</pre> | ||
is also slower than GetInSameCell. However, this might also mean that 2 GetParentCell functions might be faster than 2 GetInSameCell functions. | is also slower than GetInSameCell. However, this might also mean that 2 GetParentCell functions might be faster than 2 GetInSameCell functions. | ||
[[Category:Code Optimization]] |
Revision as of 00:42, 2 October 2007
(Still in progress)
Here's a list of comparisons of functionally equivalent scripts.
If you would like to contribute, post the scripts that you're comparing. Make sure the scripts are functionally equivalent, at least they can be interchanged in most cases. Also, note that the scripts don't have to actually do anything themselves, but can be parts of other scripts (but only test these particular snippets).
'If' vs. 'Set'
If you need to make sure a variable is set to a certain number every time the script runs, is it faster to set the number or use an if test to make sure it's the same. A good example would be setting the fQuestDelayTime for a quest. Here's the two scripts:
scn aaaTestScript float fQuestDelayTime begin GameMode if (fQuestDelayTime != .01) set fQuestDelayTime to .01 endif end
and
scn aaaTestScript float fQuestDelayTime begin GameMode set fQuestDelayTime to .01 end
Tests haven't been done yet.
GetParentCell vs. GetInSameCell
To check whether an object is in the same cell as another, you could use
if (Object1.GetInSameCell Object2)
or
if (Object1.GetParentCell == Object2.GetParentCell)
It's faster to use GetInSameCell.
Also, GetParentCell seems to cause the same FPS drop whether you use it once or twice, so
if (Object1.GetParentCell == SomeCell)
is also slower than GetInSameCell. However, this might also mean that 2 GetParentCell functions might be faster than 2 GetInSameCell functions.