OsGetRegionStats

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Added LSL Script from Godfrey)
(Documented the function more completely, including the constants used to address the returned list elements. Added templates.)
Line 1: Line 1:
 +
{{Template:Quicklinks}}
 +
[[Technical Reference | Technical Reference]] -> [[Technical Reference/terms | Terms]] -> [[Status | Status Page]] -> [[OSSL_Implemented| OSSL Implemented Functions]] -> [[OsGetRegionStatistics|osGetRegionStatistics]]
 +
 +
 +
LSL: '''[[list]] osGetRegionStats()'''<br />
 +
C#: '''[[LSL_List]] osGetRegionStats()'''
 +
 +
Returns a list of float values representing a number of region statistics (many of the values shown in the "Stats Bar" of LL-based clients).
 +
 +
This function has a [[threat level]] of Moderate, to prevent griefing scripts from obtaining metrics to gauge their own effectiveness. Please see the [[threat level]] page for information on how to enable the use of this function securely.
 +
 +
The elements in the list may be referred to by the following new LSL constants:
 +
 +
{| style="white-space:nowrap;margin-left:3em;border:1px solid black" cellspacing="0" border="1"
 +
|STATS_TIME_DILATION
 +
|0
 +
|STATS_IMAGE_MS
 +
|11
 +
|-
 +
|STATS_SIM_FPS
 +
|1
 +
|STATS_OTHER_MS
 +
|12
 +
|-
 +
|STATS_PHYSICS_FPS
 +
|2
 +
|STATS_IN_PACKETS_PER_SECOND
 +
|13
 +
|-
 +
|STATS_AGENT_UPDATES
 +
|3
 +
|STATS_OUT_PACKETS_PER_SECOND
 +
|14
 +
|-
 +
|STATS_ROOT_AGENTS
 +
|4
 +
|STATS_UNACKED_BYTES
 +
|15
 +
|-
 +
|STATS_CHILD_AGENTS
 +
|5
 +
|STATS_AGENT_MS
 +
|16
 +
|-
 +
|STATS_TOTAL_PRIMS
 +
|6
 +
|STATS_PENDING_DOWNLOADS
 +
|17
 +
|-
 +
|STATS_ACTIVE_PRIMS
 +
|7
 +
|STATS_PENDING_UPLOADS
 +
|18
 +
|-
 +
|STATS_FRAME_MS
 +
|8
 +
|STATS_ACTIVE_SCRIPTS
 +
|19
 +
|-
 +
|STATS_NET_MS
 +
|9
 +
|STATS_SCRIPT_LPS
 +
|20
 +
|-
 +
|STATS_PHYSICS_MS
 +
|10
 +
|
 +
|
 +
|}
 +
 +
Please note that as of November 2009, some of the elements in the array (to wit, the STATS_*_MS values) do not appear to contain useful information.
 +
 
Code provided by Implementor:&nbsp; Godfrey and Implemented in Git Hash 9d05962029fe864408d287d5fa7ef81f312e098a, - Rev 11601  
 
Code provided by Implementor:&nbsp; Godfrey and Implemented in Git Hash 9d05962029fe864408d287d5fa7ef81f312e098a, - Rev 11601  
  
<source lang="ini">default
+
Example script:
 +
 
 +
<source lang="lsl">
 +
// llGetRegionStats() example script
 +
//
 +
// Displays certain region statistics in hovertext above the prim containing the script.
 +
//
 +
default
 
{
 
{
state_entry()
+
    state_entry()
{
+
    {
llSetTimerEvent( 5.0 );
+
        llSetTimerEvent( 5.0 );
}
+
    }
 
   
 
   
timer()
+
    timer()
{
+
    {
list Stats = osGetRegionStats();
+
        list Stats = osGetRegionStats();
string s = "Sim FPS: " + (string) llList2Float( Stats, STATS_SIM_FPS ) + "\n";
+
        string s = "Sim FPS: " + (string) llList2Float( Stats, STATS_SIM_FPS ) + "\n";
s += "Physics FPS: " + (string) llList2Float( Stats, STATS_PHYSICS_FPS ) + "\n";
+
        s += "Physics FPS: " + (string) llList2Float( Stats, STATS_PHYSICS_FPS ) + "\n";
s += "Time Dilation: " + (string) llList2Float( Stats, STATS_TIME_DILATION ) + "\n";
+
        s += "Time Dilation: " + (string) llList2Float( Stats, STATS_TIME_DILATION ) + "\n";
s += "Root Agents: " + (string) llList2Integer( Stats, STATS_ROOT_AGENTS ) + "\n";
+
        s += "Root Agents: " + (string) llList2Integer( Stats, STATS_ROOT_AGENTS ) + "\n";
s += "Child Agents: " + (string) llList2Integer( Stats, STATS_CHILD_AGENTS ) + "\n";
+
        s += "Child Agents: " + (string) llList2Integer( Stats, STATS_CHILD_AGENTS ) + "\n";
s += "Total Prims: " + (string) llList2Integer( Stats, STATS_TOTAL_PRIMS ) + "\n";
+
        s += "Total Prims: " + (string) llList2Integer( Stats, STATS_TOTAL_PRIMS ) + "\n";
s += "Active Scripts: " + (string) llList2Integer( Stats, STATS_ACTIVE_SCRIPTS ) + "\n";
+
        s += "Active Scripts: " + (string) llList2Integer( Stats, STATS_ACTIVE_SCRIPTS ) + "\n";
s += "Script LPS: " + (string) llList2Float( Stats, STATS_SCRIPT_LPS );
+
        s += "Script LPS: " + (string) llList2Float( Stats, STATS_SCRIPT_LPS );
llSetText( s, <0.0,1.0,0.0>, 1.0 );
+
        llSetText( s, <0.0,1.0,0.0>, 1.0 );
}
+
    }
 
}</source>
 
}</source>

Revision as of 08:50, 27 November 2009

Technical Reference -> Terms -> Status Page -> OSSL Implemented Functions -> osGetRegionStatistics


LSL: list osGetRegionStats()
C#: LSL_List osGetRegionStats()

Returns a list of float values representing a number of region statistics (many of the values shown in the "Stats Bar" of LL-based clients).

This function has a threat level of Moderate, to prevent griefing scripts from obtaining metrics to gauge their own effectiveness. Please see the threat level page for information on how to enable the use of this function securely.

The elements in the list may be referred to by the following new LSL constants:

STATS_TIME_DILATION 0 STATS_IMAGE_MS 11
STATS_SIM_FPS 1 STATS_OTHER_MS 12
STATS_PHYSICS_FPS 2 STATS_IN_PACKETS_PER_SECOND 13
STATS_AGENT_UPDATES 3 STATS_OUT_PACKETS_PER_SECOND 14
STATS_ROOT_AGENTS 4 STATS_UNACKED_BYTES 15
STATS_CHILD_AGENTS 5 STATS_AGENT_MS 16
STATS_TOTAL_PRIMS 6 STATS_PENDING_DOWNLOADS 17
STATS_ACTIVE_PRIMS 7 STATS_PENDING_UPLOADS 18
STATS_FRAME_MS 8 STATS_ACTIVE_SCRIPTS 19
STATS_NET_MS 9 STATS_SCRIPT_LPS 20
STATS_PHYSICS_MS 10

Please note that as of November 2009, some of the elements in the array (to wit, the STATS_*_MS values) do not appear to contain useful information.

Code provided by Implementor:  Godfrey and Implemented in Git Hash 9d05962029fe864408d287d5fa7ef81f312e098a, - Rev 11601

Example script:

// llGetRegionStats() example script
//
// Displays certain region statistics in hovertext above the prim containing the script.
//
default
{
    state_entry()
    {
        llSetTimerEvent( 5.0 );
    }
 
    timer()
    {
        list Stats = osGetRegionStats();
        string s = "Sim FPS: " + (string) llList2Float( Stats, STATS_SIM_FPS ) + "\n";
        s += "Physics FPS: " + (string) llList2Float( Stats, STATS_PHYSICS_FPS ) + "\n";
        s += "Time Dilation: " + (string) llList2Float( Stats, STATS_TIME_DILATION ) + "\n";
        s += "Root Agents: " + (string) llList2Integer( Stats, STATS_ROOT_AGENTS ) + "\n";
        s += "Child Agents: " + (string) llList2Integer( Stats, STATS_CHILD_AGENTS ) + "\n";
        s += "Total Prims: " + (string) llList2Integer( Stats, STATS_TOTAL_PRIMS ) + "\n";
        s += "Active Scripts: " + (string) llList2Integer( Stats, STATS_ACTIVE_SCRIPTS ) + "\n";
        s += "Script LPS: " + (string) llList2Float( Stats, STATS_SCRIPT_LPS );
        llSetText( s, <0.0,1.0,0.0>, 1.0 );
    }
}
Personal tools
General
About This Wiki