Enables or disables the scripts profiling state.

Syntax

void llScriptProfiler( integer flags );

Forced delay: 0.0 seconds. Energy: 10.0.

Parameters

integer flags
PROFILE_* flags

Specification

This function's behavior is dependent upon the VM the script is using. Mono is the new VM, LSO is the old VM. The big difference between Mono and LSO is that Mono scripts run faster and can utilize four times more memory.

Mono

Use this function with PROFILE_SCRIPT_MEMORY to enable memory profiling at a severe script performance penalty. Use it with PROFILE_NONE to disable profiling. During and after a profiling run llGetSPMaxMemory will return the most memory used at any one time.

LSO

This function has no effect for scripts not compiled to Mono.

Constants

ConstantValDescription
PROFILE_NONE0Disables profiling
PROFILE_SCRIPT_MEMORY1Enables memory profiling

Caveats

Examples

Calling llScriptProfiler can look like this:

llScriptProfiler(PROFILE_SCRIPT_MEMORY);
my_func();
llScriptProfiler(PROFILE_NONE);
llOwnerSay("This script used at most " + (string)llGetSPMaxMemory() + " bytes of memory during my_func.");

This is how it looks in a script as an example:

// need to run something for the profile to register... 
workerMethod()
{
    float mathNumber = 3 * PI + 3 * llSin( PI );
    llSetText( "Answer: " + (string)mathNumber, <1, 0, 0>, 1.0 );
}

default
{
    state_entry()
    {
        llSetMemoryLimit( 5000 ); // set the memory limit
        
        // call up the profiler, execute a method, stop profiler
        llScriptProfiler( PROFILE_SCRIPT_MEMORY );
        workerMethod(); 
        llScriptProfiler( PROFILE_NONE );
        
        // display memory usage...
        llSay(0, "Memory used: " + (string)llGetSPMaxMemory() + " bytes, total memory: " + 
            (string)llGetMemoryLimit() + " bytes." );
    }
}

// outputs 
// Object: Memory used: 4968 bytes, total memory: 5000 bytes.

See also

Functions

Deep notes

History

Date of Release 17/06/2011