diff options
author | Talun | 2012-04-10 21:25:05 +0100 |
---|---|---|
committer | nebadon | 2012-04-12 18:44:00 -0700 |
commit | 08e509978d81cb3451c205ed59648e3f5da91344 (patch) | |
tree | e8fb382ef1661c2d370c64915a05376b295c551e /OpenSim/Region/Framework | |
parent | make changes to FlotsamCache.ini.example as noted in mantis #5960 (diff) | |
download | opensim-SC-08e509978d81cb3451c205ed59648e3f5da91344.zip opensim-SC-08e509978d81cb3451c205ed59648e3f5da91344.tar.gz opensim-SC-08e509978d81cb3451c205ed59648e3f5da91344.tar.bz2 opensim-SC-08e509978d81cb3451c205ed59648e3f5da91344.tar.xz |
Mantis 55025 Implement script time.
Signed-off-by: nebadon <michael@osgrid.org>
Diffstat (limited to 'OpenSim/Region/Framework')
5 files changed, 84 insertions, 8 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index f5dda34..30ed7d1 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs | |||
@@ -172,7 +172,17 @@ namespace OpenSim.Region.Framework.Interfaces | |||
172 | /// If no inventory item has that name then an empty list is returned. | 172 | /// If no inventory item has that name then an empty list is returned. |
173 | /// </returns> | 173 | /// </returns> |
174 | List<TaskInventoryItem> GetInventoryItems(string name); | 174 | List<TaskInventoryItem> GetInventoryItems(string name); |
175 | 175 | ||
176 | /// <summary> | ||
177 | /// Get inventory items by type. | ||
178 | /// </summary> | ||
179 | /// <param type="name"></param> | ||
180 | /// <returns> | ||
181 | /// A list of inventory items of that type. | ||
182 | /// If no inventory items of that type then an empty list is returned. | ||
183 | /// </returns> | ||
184 | List<TaskInventoryItem> GetInventoryItems(InventoryType type); | ||
185 | |||
176 | /// <summary> | 186 | /// <summary> |
177 | /// Get the scene object referenced by an inventory item. | 187 | /// Get the scene object referenced by an inventory item. |
178 | /// </summary> | 188 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index c0616ed..0d488df 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs | |||
@@ -83,6 +83,14 @@ namespace OpenSim.Region.Framework.Interfaces | |||
83 | void StartProcessing(); | 83 | void StartProcessing(); |
84 | 84 | ||
85 | /// <summary> | 85 | /// <summary> |
86 | /// Get the execution times of all scripts in the given array if they are currently running. | ||
87 | /// </summary> | ||
88 | /// <returns> | ||
89 | /// A float the value is a representative execution time in milliseconds of all scripts in that Array. | ||
90 | /// </returns> | ||
91 | float GetScriptExecutionTime(List<UUID> itemIDs); | ||
92 | |||
93 | /// <summary> | ||
86 | /// Get the execution times of all scripts in each object. | 94 | /// Get the execution times of all scripts in each object. |
87 | /// </summary> | 95 | /// </summary> |
88 | /// <returns> | 96 | /// <returns> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 7d14814..a49ed13 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -3270,6 +3270,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
3270 | } | 3270 | } |
3271 | 3271 | ||
3272 | /// <summary> | 3272 | /// <summary> |
3273 | /// A float the value is a representative execution time in milliseconds of all scripts in the link set. | ||
3274 | /// </summary> | ||
3275 | public float ScriptExecutionTime() | ||
3276 | { | ||
3277 | IScriptModule[] engines = Scene.RequestModuleInterfaces<IScriptModule>(); | ||
3278 | |||
3279 | if (engines.Length == 0) // No engine at all | ||
3280 | return 0.0f; | ||
3281 | |||
3282 | float time = 0.0f; | ||
3283 | |||
3284 | // get all the scripts in all parts | ||
3285 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
3286 | List<TaskInventoryItem> scripts = new List<TaskInventoryItem>(); | ||
3287 | for (int i = 0; i < parts.Length; i++) | ||
3288 | { | ||
3289 | scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL)); | ||
3290 | } | ||
3291 | // extract the UUIDs | ||
3292 | List<UUID> ids = new List<UUID>(scripts.Count); | ||
3293 | foreach (TaskInventoryItem script in scripts) | ||
3294 | { | ||
3295 | if (!ids.Contains(script.ItemID)) | ||
3296 | { | ||
3297 | ids.Add(script.ItemID); | ||
3298 | } | ||
3299 | } | ||
3300 | // Offer the list of script UUIDs to each engine found and accumulate the time | ||
3301 | foreach (IScriptModule e in engines) | ||
3302 | { | ||
3303 | if (e != null) | ||
3304 | { | ||
3305 | time += e.GetScriptExecutionTime(ids); | ||
3306 | } | ||
3307 | } | ||
3308 | return time; | ||
3309 | } | ||
3310 | |||
3311 | /// <summary> | ||
3273 | /// Returns a count of the number of running scripts in this groups parts. | 3312 | /// Returns a count of the number of running scripts in this groups parts. |
3274 | /// </summary> | 3313 | /// </summary> |
3275 | public int RunningScriptCount() | 3314 | public int RunningScriptCount() |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 9a04c65..aacad98 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -222,7 +222,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
222 | /// </summary> | 222 | /// </summary> |
223 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) | 223 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) |
224 | { | 224 | { |
225 | List<TaskInventoryItem> scripts = GetInventoryScripts(); | 225 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
226 | foreach (TaskInventoryItem item in scripts) | 226 | foreach (TaskInventoryItem item in scripts) |
227 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | 227 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); |
228 | } | 228 | } |
@@ -255,7 +255,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
255 | /// </param> | 255 | /// </param> |
256 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) | 256 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) |
257 | { | 257 | { |
258 | List<TaskInventoryItem> scripts = GetInventoryScripts(); | 258 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
259 | foreach (TaskInventoryItem item in scripts) | 259 | foreach (TaskInventoryItem item in scripts) |
260 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); | 260 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); |
261 | } | 261 | } |
@@ -1116,7 +1116,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1116 | return 0; | 1116 | return 0; |
1117 | 1117 | ||
1118 | int count = 0; | 1118 | int count = 0; |
1119 | List<TaskInventoryItem> scripts = GetInventoryScripts(); | 1119 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
1120 | 1120 | ||
1121 | foreach (TaskInventoryItem item in scripts) | 1121 | foreach (TaskInventoryItem item in scripts) |
1122 | { | 1122 | { |
@@ -1157,14 +1157,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1157 | return ret; | 1157 | return ret; |
1158 | } | 1158 | } |
1159 | 1159 | ||
1160 | public List<TaskInventoryItem> GetInventoryScripts() | 1160 | public List<TaskInventoryItem> GetInventoryItems(InventoryType type) |
1161 | { | 1161 | { |
1162 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1162 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1163 | 1163 | ||
1164 | lock (m_items) | 1164 | lock (m_items) |
1165 | { | 1165 | { |
1166 | foreach (TaskInventoryItem item in m_items.Values) | 1166 | foreach (TaskInventoryItem item in m_items.Values) |
1167 | if (item.InvType == (int)InventoryType.LSL) | 1167 | if (item.InvType == (int)type) |
1168 | ret.Add(item); | 1168 | ret.Add(item); |
1169 | } | 1169 | } |
1170 | 1170 | ||
@@ -1183,7 +1183,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1183 | if (engines.Length == 0) // No engine at all | 1183 | if (engines.Length == 0) // No engine at all |
1184 | return ret; | 1184 | return ret; |
1185 | 1185 | ||
1186 | List<TaskInventoryItem> scripts = GetInventoryScripts(); | 1186 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
1187 | 1187 | ||
1188 | foreach (TaskInventoryItem item in scripts) | 1188 | foreach (TaskInventoryItem item in scripts) |
1189 | { | 1189 | { |
@@ -1211,7 +1211,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1211 | if (engines.Length == 0) | 1211 | if (engines.Length == 0) |
1212 | return; | 1212 | return; |
1213 | 1213 | ||
1214 | List<TaskInventoryItem> scripts = GetInventoryScripts(); | 1214 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
1215 | 1215 | ||
1216 | foreach (TaskInventoryItem item in scripts) | 1216 | foreach (TaskInventoryItem item in scripts) |
1217 | { | 1217 | { |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8863df1..641d742 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -3438,6 +3438,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
3438 | } | 3438 | } |
3439 | 3439 | ||
3440 | /// <summary> | 3440 | /// <summary> |
3441 | /// A float the value is a representative execution time in milliseconds of all scripts in all attachments. | ||
3442 | /// </summary> | ||
3443 | public float ScriptExecutionTime() | ||
3444 | { | ||
3445 | float time = 0.0f; | ||
3446 | lock (m_attachments) | ||
3447 | { | ||
3448 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3449 | { | ||
3450 | if (gobj != null) | ||
3451 | { | ||
3452 | time += gobj.ScriptExecutionTime(); | ||
3453 | } | ||
3454 | } | ||
3455 | } | ||
3456 | return time; | ||
3457 | } | ||
3458 | |||
3459 | /// <summary> | ||
3441 | /// Returns the total count of running scripts in all parts. | 3460 | /// Returns the total count of running scripts in all parts. |
3442 | /// </summary> | 3461 | /// </summary> |
3443 | public int RunningScriptCount() | 3462 | public int RunningScriptCount() |