Resource Impact Calculator
Revision as of 14:31, 20 August 2012 by SmarTek Engineer (talk | contribs) (Created page with "{{LSL Header}} ====Resource Impact Calculator==== <lsl> /* Sim resource impact calculator. Call impactCPU(uuid) or/and impactRAM(uuid) to get the percentage of allowed resour…")
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Resource Impact Calculator
<lsl> /*
Sim resource impact calculator. Call impactCPU(uuid) or/and impactRAM(uuid) to get the percentage of allowed resources the avatar is using. Data returned is integer type [0-100].
- /
integer maxRAM=200000000; // 200MB server RAM is usually what simulators use for scripting float maxload=0.040;// Maximum allowed latency in miliseconds due scripting load on the simulator, 40-80ms is normal. integer maxavi=100;// Avatars the simulator can host.
integer impactCPU(key id){ return (integer)(llList2Float(llGetObjectDetails(id, [OBJECT_SCRIPT_TIME]), 0)/(maxload/maxavi*maxavi/llGetRegionAgentCount())*100); } integer impactRAM(key id){ return (integer)(llList2Float(llGetObjectDetails(id, [OBJECT_SCRIPT_MEMORY]), 0)/(maxRAM/maxavi*maxavi/llGetRegionAgentCount())*100); }
default
{
touch_start(integer num_detected) { key id=llDetectedKey(0); llInstantMessage(id,"CPU usage: "+(string)(impactCPU(id))+"%"); llInstantMessage(id,"RAM usage: "+(string)(impactRAM(id))+"%");//example of informational message if(impactRAM(id)>100)llInstantMessage(id,"You've hit the memory usage limit."); //example of warning message if(impactCPU(id)>100)llInstantMessage(id,"You've hit the CPU usage limit."); }
} </lsl>