Difference between revisions of "Performance Problems"
imported>Haama (Not so bad, after all, fixed a few links) |
imported>WalkerInShadows |
||
(6 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
__TOC__ | |||
This section is intended as a place to list performance problems and tips, especially those related to scripting. | This section is intended as a place to list performance problems and tips, especially those related to scripting. | ||
Line 26: | Line 26: | ||
# [[GetNumItems]] (OBSE) | # [[GetNumItems]] (OBSE) | ||
# [[GetInventoryObject]] (OBSE) | # [[GetInventoryObject]] (OBSE) | ||
#*Inventory functions became faster with OBSE 0013 (beta) (it uses an improved algorithm), see also [http://www.bethsoft.com/bgsforums/index.php?showtopic=772701&st=0 this thread]. [[User:Tibixe|Tibixe]] | |||
#**[http://www.bethsoft.com/bgsforums/index.php?s=&showtopic=772701&view=findpost&p=11209205 See this post for more information.] Basically, it's much faster now for inventories with only a few items in it, but still somewhat slow for larger inventories (50 GIOs per frame for 150 item inventory causes a drop of 1 FPS).--[[User:Haama|Haama]] 00:50, 10 November 2007 (EST) | |||
# [[GetFPS]] (OBSE) | # [[GetFPS]] (OBSE) | ||
#* However, you can run this every few frames without a drop. This is most useful as an alternative to '''GetSecondsPassed''' as ((Number of frames passed) / GetFPS) approximates the amount of time passed. | #* However, you can run this every few frames without a drop. This is most useful as an alternative to '''GetSecondsPassed''' as ((Number of frames passed) / GetFPS) approximates the amount of time passed. | ||
Line 31: | Line 33: | ||
#* I have tested the others above, but not this one. However, I have seen it mentioned several times that GetDistance is a CPU heavy function, so I'm including it here. | #* I have tested the others above, but not this one. However, I have seen it mentioned several times that GetDistance is a CPU heavy function, so I'm including it here. | ||
#*--[[User:Haama|Haama]] 17:54, 10 September 2007 (EDT) | #*--[[User:Haama|Haama]] 17:54, 10 September 2007 (EDT) | ||
#* [http://forums.bethsoft.com/index.php?/topic/1145441-does-getdistance-called-every-frame-hurt-frame-rate-or-not Discussion about GetDistance] that seems to imply the function is not so CPU-hungry. | |||
Note that for all of these, they are incredibly fast functions. Even the slowest, GetInventoryObject, can be run 1000 times and the next frame will come up in less than a second. They will only cause problems if run them constantly (every frame or so). | Note that for all of these, they are incredibly fast functions. Even the slowest, GetInventoryObject, can be run 1000 times and the next frame will come up in less than a second. They will only cause problems if run them constantly (every frame or so). | ||
Line 36: | Line 39: | ||
The main problem with CPU-hungry scripts comes from Oblivion's "brick-wall" for FPS and script processing. Scripts won't touch FPS until you hit a certain limit, and then even a few extra small scripts can start dropping FPS. | The main problem with CPU-hungry scripts comes from Oblivion's "brick-wall" for FPS and script processing. Scripts won't touch FPS until you hit a certain limit, and then even a few extra small scripts can start dropping FPS. | ||
See [[Code Optimization]] for more details (in planning/progress). | See [[:Category:Code Optimization]] for more details (in planning/progress). | ||
== AI Overload == | == AI Overload == | ||
Line 45: | Line 48: | ||
== Low-Level Processing == | == Low-Level Processing == | ||
Avoid low-level processing for as many creatures and NPCs as possible. Use the "No Low Level Processing" option to keep them from processing their AI unless the player is in the same cell. | Avoid low-level processing for as many creatures and NPCs as possible. Use the "No Low Level Processing" option to keep them from processing their AI unless the player is in the same cell. | ||
Note: If an NPC never leaves an interior cell, then this should be ticked, but if their AI packages has them moving between interior cells or travelling between interior and exterior or travelling from one end of a city to another (or further) then this should not be ticked, otherwise the NPC will never be where they're meant to be, they'll always be in the cell they are initially placed in. They would only leave that cell to follow their AI if you then enter that cell, but as soon as they leave the cell they will be dropped from memory again and so won't reach their destination unless the player follows them the whole way. (Thanks Vorians!) | |||
[[Category:Troubleshooting]] | [[Category:Troubleshooting]] |
Latest revision as of 15:38, 25 December 2012
This section is intended as a place to list performance problems and tips, especially those related to scripting.
Gamemode Scripts[edit | edit source]
Avoid using gamemode scripts wherever possible. Use quest scripts if you can, or try to find ways to put as much of the script work into OnLoad, OnEquip, and ScriptEffectStart blocks as possible.
If you need to use a GameMode block, use an 'if' test or a flag so the code will only run when necessary. For instance, if you need to run an item script whenever the player hits a switch, place this on the switch:
scn YourSwitchScript short Working begin onActivate set Working to 1 end
and this on the item:
scn YourItemScript begin GameMode if YourSwitchScript.Working ... endif end
CPU-Hungry Script Functions[edit | edit source]
Generally, scripts have little affect on FPS, especially compared to graphics. However, if run every frame there are a few functions that will cause a noticeable (>1) drop in FPS:
- GetNumItems (OBSE)
- GetInventoryObject (OBSE)
- Inventory functions became faster with OBSE 0013 (beta) (it uses an improved algorithm), see also this thread. Tibixe
- See this post for more information. Basically, it's much faster now for inventories with only a few items in it, but still somewhat slow for larger inventories (50 GIOs per frame for 150 item inventory causes a drop of 1 FPS).--Haama 00:50, 10 November 2007 (EST)
- Inventory functions became faster with OBSE 0013 (beta) (it uses an improved algorithm), see also this thread. Tibixe
- GetFPS (OBSE)
- However, you can run this every few frames without a drop. This is most useful as an alternative to GetSecondsPassed as ((Number of frames passed) / GetFPS) approximates the amount of time passed.
- GetDistance
- I have tested the others above, but not this one. However, I have seen it mentioned several times that GetDistance is a CPU heavy function, so I'm including it here.
- --Haama 17:54, 10 September 2007 (EDT)
- Discussion about GetDistance that seems to imply the function is not so CPU-hungry.
Note that for all of these, they are incredibly fast functions. Even the slowest, GetInventoryObject, can be run 1000 times and the next frame will come up in less than a second. They will only cause problems if run them constantly (every frame or so).
The main problem with CPU-hungry scripts comes from Oblivion's "brick-wall" for FPS and script processing. Scripts won't touch FPS until you hit a certain limit, and then even a few extra small scripts can start dropping FPS.
See Category:Code Optimization for more details (in planning/progress).
AI Overload[edit | edit source]
If you use advanced AI on a lot of NPCs or creatures, the game may start to suffer from so-called "AI overload", causing NPCs and creatures to fail to process their AI as you approach them. This can do nasty things like giving roadside bandits a lobotomy -- they just stand around and do nothing as you approach.
Creatures that are swimming seem to put an extra large burden on the system, possibly because the pathfinding is trickier in the water?
Low-Level Processing[edit | edit source]
Avoid low-level processing for as many creatures and NPCs as possible. Use the "No Low Level Processing" option to keep them from processing their AI unless the player is in the same cell.
Note: If an NPC never leaves an interior cell, then this should be ticked, but if their AI packages has them moving between interior cells or travelling between interior and exterior or travelling from one end of a city to another (or further) then this should not be ticked, otherwise the NPC will never be where they're meant to be, they'll always be in the cell they are initially placed in. They would only leave that cell to follow their AI if you then enter that cell, but as soon as they leave the cell they will be dropped from memory again and so won't reach their destination unless the player follows them the whole way. (Thanks Vorians!)