diff options
author | Oren Hurvitz | 2015-07-31 15:34:43 +0300 |
---|---|---|
committer | Oren Hurvitz | 2015-08-11 08:44:26 +0100 |
commit | d24528b3bc2c277edae3507428bfeb23e5d81f57 (patch) | |
tree | 87bed067dac438708be872a4ebc892de0e30a4ab /OpenSim/Region/Framework/Scenes | |
parent | Changed "Script Execution Time" to be the gross time, i.e. including handling... (diff) | |
download | opensim-SC-d24528b3bc2c277edae3507428bfeb23e5d81f57.zip opensim-SC-d24528b3bc2c277edae3507428bfeb23e5d81f57.tar.gz opensim-SC-d24528b3bc2c277edae3507428bfeb23e5d81f57.tar.bz2 opensim-SC-d24528b3bc2c277edae3507428bfeb23e5d81f57.tar.xz |
Show Script Time in the statistics panel
The value shown is the number of milliseconds per frame that were spent executing scripts in this region.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rwxr-xr-x | OpenSim/Region/Framework/Scenes/Scene.cs | 26 | ||||
-rwxr-xr-x | OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | 80 |
2 files changed, 68 insertions, 38 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2a69ee1..24c95d1 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -445,6 +445,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
445 | private int m_lastMaintenanceTick; | 445 | private int m_lastMaintenanceTick; |
446 | 446 | ||
447 | /// <summary> | 447 | /// <summary> |
448 | /// Total script execution time (in Stopwatch Ticks) since the last frame | ||
449 | /// </summary> | ||
450 | private long m_scriptExecutionTime = 0; | ||
451 | |||
452 | /// <summary> | ||
448 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched | 453 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched |
449 | /// asynchronously from the update loop. | 454 | /// asynchronously from the update loop. |
450 | /// </summary> | 455 | /// </summary> |
@@ -1926,6 +1931,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1926 | StatsReporter.addOtherMS(otherMS); | 1931 | StatsReporter.addOtherMS(otherMS); |
1927 | StatsReporter.AddSpareMS(spareMS); | 1932 | StatsReporter.AddSpareMS(spareMS); |
1928 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | 1933 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); |
1934 | StatsReporter.AddScriptMS((int) GetAndResetScriptExecutionTime()); | ||
1929 | 1935 | ||
1930 | // Send the correct time values to the stats reporter for the | 1936 | // Send the correct time values to the stats reporter for the |
1931 | // frame times | 1937 | // frame times |
@@ -1953,6 +1959,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
1953 | return spareMS >= 0; | 1959 | return spareMS >= 0; |
1954 | } | 1960 | } |
1955 | 1961 | ||
1962 | /// <summary> | ||
1963 | /// Adds the execution time of one script to the total scripts execution time for this region. | ||
1964 | /// </summary> | ||
1965 | /// <param name="ticks">Elapsed Stopwatch ticks</param> | ||
1966 | public void AddScriptExecutionTime(long ticks) | ||
1967 | { | ||
1968 | Interlocked.Add(ref m_scriptExecutionTime, ticks); | ||
1969 | } | ||
1970 | |||
1971 | /// <summary> | ||
1972 | /// Returns the total execution time of all the scripts in the region since the last frame | ||
1973 | /// (in milliseconds), and clears the value in preparation for the next frame. | ||
1974 | /// </summary> | ||
1975 | /// <returns>Time in milliseconds</returns> | ||
1976 | private long GetAndResetScriptExecutionTime() | ||
1977 | { | ||
1978 | long ticks = Interlocked.Exchange(ref m_scriptExecutionTime, 0); | ||
1979 | return (ticks * 1000) / Stopwatch.Frequency; | ||
1980 | } | ||
1981 | |||
1956 | public void AddGroupTarget(SceneObjectGroup grp) | 1982 | public void AddGroupTarget(SceneObjectGroup grp) |
1957 | { | 1983 | { |
1958 | lock (m_groupsWithTargets) | 1984 | lock (m_groupsWithTargets) |
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 8918c3b..4847696 100755 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | |||
@@ -63,7 +63,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
63 | 63 | ||
64 | // Determines the size of the array that is used to collect StatBlocks | 64 | // Determines the size of the array that is used to collect StatBlocks |
65 | // for sending to the SimStats and SimExtraStatsCollector | 65 | // for sending to the SimStats and SimExtraStatsCollector |
66 | private const int m_statisticArraySize = 27; | 66 | private const int m_statisticArraySize = 28; |
67 | 67 | ||
68 | /// <summary> | 68 | /// <summary> |
69 | /// These are the IDs of stats sent in the StatsPacket to the viewer. | 69 | /// These are the IDs of stats sent in the StatsPacket to the viewer. |
@@ -204,9 +204,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
204 | private int m_physicsMS; | 204 | private int m_physicsMS; |
205 | private int m_imageMS; | 205 | private int m_imageMS; |
206 | private int m_otherMS; | 206 | private int m_otherMS; |
207 | 207 | private int m_scriptMS; | |
208 | //Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. | ||
209 | //Ckrinke private int m_scriptMS = 0; | ||
210 | 208 | ||
211 | private int m_rootAgents; | 209 | private int m_rootAgents; |
212 | private int m_childAgents; | 210 | private int m_childAgents; |
@@ -428,7 +426,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
428 | // values to X-per-second values. | 426 | // values to X-per-second values. |
429 | 427 | ||
430 | uint thisFrame = m_scene.Frame; | 428 | uint thisFrame = m_scene.Frame; |
431 | float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor; | 429 | uint numFrames = thisFrame - m_lastUpdateFrame; |
430 | float framesUpdated = (float)numFrames * m_reportedFpsCorrectionFactor; | ||
432 | m_lastUpdateFrame = thisFrame; | 431 | m_lastUpdateFrame = thisFrame; |
433 | 432 | ||
434 | // Avoid div-by-zero if somehow we've not updated any frames. | 433 | // Avoid div-by-zero if somehow we've not updated any frames. |
@@ -501,23 +500,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
501 | // statistics to the statistics window | 500 | // statistics to the statistics window |
502 | sb[8].StatID = (uint)Stats.FrameMS; | 501 | sb[8].StatID = (uint)Stats.FrameMS; |
503 | //sb[8].StatValue = m_frameMS / framesUpdated; | 502 | //sb[8].StatValue = m_frameMS / framesUpdated; |
504 | sb[8].StatValue = (float) totalSumFrameTime / m_numberFramesStored; | 503 | sb[8].StatValue = (float) totalSumFrameTime / m_numberFramesStored; |
505 | 504 | ||
506 | sb[9].StatID = (uint)Stats.NetMS; | 505 | sb[9].StatID = (uint)Stats.NetMS; |
507 | //sb[9].StatValue = m_netMS / framesUpdated; | 506 | //sb[9].StatValue = m_netMS / framesUpdated; |
508 | sb[9].StatValue = (float) networkSumFrameTime / m_numberFramesStored; | 507 | sb[9].StatValue = (float) networkSumFrameTime / m_numberFramesStored; |
509 | 508 | ||
510 | sb[10].StatID = (uint)Stats.PhysicsMS; | 509 | sb[10].StatID = (uint)Stats.PhysicsMS; |
511 | //sb[10].StatValue = m_physicsMS / framesUpdated; | 510 | //sb[10].StatValue = m_physicsMS / framesUpdated; |
512 | sb[10].StatValue = (float) physicsSumFrameTime / m_numberFramesStored; | 511 | sb[10].StatValue = (float) physicsSumFrameTime / m_numberFramesStored; |
513 | 512 | ||
514 | sb[11].StatID = (uint)Stats.ImageMS ; | 513 | sb[11].StatID = (uint)Stats.ImageMS ; |
515 | sb[11].StatValue = m_imageMS / framesUpdated; | 514 | sb[11].StatValue = m_imageMS / framesUpdated; |
516 | 515 | ||
517 | sb[12].StatID = (uint)Stats.OtherMS; | 516 | sb[12].StatID = (uint)Stats.OtherMS; |
518 | //sb[12].StatValue = m_otherMS / framesUpdated; | 517 | //sb[12].StatValue = m_otherMS / framesUpdated; |
519 | sb[12].StatValue = (float) simulationSumFrameTime / | 518 | sb[12].StatValue = (float) simulationSumFrameTime / m_numberFramesStored; |
520 | m_numberFramesStored; | ||
521 | 519 | ||
522 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; | 520 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; |
523 | sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); | 521 | sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); |
@@ -567,6 +565,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
567 | sb[26].StatID = (uint)Stats.ThreadCount; | 565 | sb[26].StatID = (uint)Stats.ThreadCount; |
568 | sb[26].StatValue = m_inUseThreads; | 566 | sb[26].StatValue = m_inUseThreads; |
569 | 567 | ||
568 | sb[27].StatID = (uint)Stats.ScriptMS; | ||
569 | sb[27].StatValue = (numFrames <= 0) ? 0 : ((float)m_scriptMS / numFrames); | ||
570 | |||
570 | for (int i = 0; i < m_statisticArraySize; i++) | 571 | for (int i = 0; i < m_statisticArraySize; i++) |
571 | { | 572 | { |
572 | lastReportedSimStats[i] = sb[i].StatValue; | 573 | lastReportedSimStats[i] = sb[i].StatValue; |
@@ -632,10 +633,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
632 | m_physicsMS = 0; | 633 | m_physicsMS = 0; |
633 | m_imageMS = 0; | 634 | m_imageMS = 0; |
634 | m_otherMS = 0; | 635 | m_otherMS = 0; |
636 | m_scriptMS = 0; | ||
635 | m_spareMS = 0; | 637 | m_spareMS = 0; |
636 | |||
637 | //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. | ||
638 | //Ckrinke m_scriptMS = 0; | ||
639 | } | 638 | } |
640 | 639 | ||
641 | # region methods called from Scene | 640 | # region methods called from Scene |
@@ -746,31 +745,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
746 | m_otherMS += ms; | 745 | m_otherMS += ms; |
747 | } | 746 | } |
748 | 747 | ||
749 | public void addPhysicsFrame(int frames) | 748 | public void AddScriptMS(int ms) |
750 | { | 749 | { |
751 | // Add the number of physics frames to the correct total physics | 750 | m_scriptMS += ms; |
752 | // frames | 751 | } |
753 | m_numberPhysicsFrames += frames; | 752 | |
754 | } | 753 | public void addPhysicsFrame(int frames) |
755 | 754 | { | |
756 | public void addFrameTimeMilliseconds(double total, double simulation, | 755 | // Add the number of physics frames to the correct total physics |
757 | double physics, double network) | 756 | // frames |
758 | { | 757 | m_numberPhysicsFrames += frames; |
759 | // Save the frame times from the current frame into the appropriate | 758 | } |
760 | // arrays | 759 | |
761 | m_totalFrameTimeMilliseconds[m_nextLocation] = total; | 760 | public void addFrameTimeMilliseconds(double total, double simulation, |
762 | m_simulationFrameTimeMilliseconds[m_nextLocation] = simulation; | 761 | double physics, double network) |
763 | m_physicsFrameTimeMilliseconds[m_nextLocation] = physics; | 762 | { |
764 | m_networkFrameTimeMilliseconds[m_nextLocation] = network; | 763 | // Save the frame times from the current frame into the appropriate |
765 | 764 | // arrays | |
766 | // Update to the next location in the list | 765 | m_totalFrameTimeMilliseconds[m_nextLocation] = total; |
767 | m_nextLocation++; | 766 | m_simulationFrameTimeMilliseconds[m_nextLocation] = simulation; |
768 | 767 | m_physicsFrameTimeMilliseconds[m_nextLocation] = physics; | |
769 | // Since the list will begin to overwrite the oldest frame values | 768 | m_networkFrameTimeMilliseconds[m_nextLocation] = network; |
770 | // first, the next location needs to loop back to the beginning of the | 769 | |
771 | // list whenever it reaches the end | 770 | // Update to the next location in the list |
772 | m_nextLocation = m_nextLocation % m_numberFramesStored; | 771 | m_nextLocation++; |
773 | } | 772 | |
773 | // Since the list will begin to overwrite the oldest frame values | ||
774 | // first, the next location needs to loop back to the beginning of the | ||
775 | // list whenever it reaches the end | ||
776 | m_nextLocation = m_nextLocation % m_numberFramesStored; | ||
777 | } | ||
774 | 778 | ||
775 | public void AddPendingDownloads(int count) | 779 | public void AddPendingDownloads(int count) |
776 | { | 780 | { |