Difference between revisions of "LLTrace"
(Created page with "== What is it? == LLTrace is our system for capturing realtime statistic related to viewer performance and behavior and (optionally) associating those metrics with certain actio…") |
(→Usage) |
||
Line 16: | Line 16: | ||
First, you need to declare a statistic that you are going to track. For example, let's say you want to create a pedometer for your avatar. If you want to know how many footsteps your avatar takes, you would declare a *count* statistic for footsteps like this: | First, you need to declare a statistic that you are going to track. For example, let's say you want to create a pedometer for your avatar. If you want to know how many footsteps your avatar takes, you would declare a *count* statistic for footsteps like this: | ||
< | <pre> | ||
static LLTrace::CountStatHandle<> sFootSteps ("footstepcount", "Number of footsteps I've taken"); | static LLTrace::CountStatHandle<> sFootSteps ("footstepcount", "Number of footsteps I've taken"); | ||
</ | </pre> | ||
This declares a handle to this particular statistic that you will use in all future reads/writes of that stat. This object needs to be a global/static variable so that when we start running SL code, we have an accurate count of how many statistics we have. Support for dynamically adding/removing stats is under consideration for a future release. | This declares a handle to this particular statistic that you will use in all future reads/writes of that stat. This object needs to be a global/static variable so that when we start running SL code, we have an accurate count of how many statistics we have. Support for dynamically adding/removing stats is under consideration for a future release. The template parameter is used to specify the type of value the statistic is stored as. Here we are using the default, which is a double precision floating point value. All values are stored as double precision floats under the hood, so don't bother optimizing for integers, etc. The first parameter is the name of the stat, used for tagging in output and runtime lookup. The second parameter is a documentation string describing what this statistic means. | ||
Next, you can record your data. For a count-like statistic, this is done through the add method: | Next, you can record your data. For a count-like statistic, this is done through the add method: | ||
< | <pre> | ||
// I took a step | // I took a step | ||
add(sFootSteps, 1); | add(sFootSteps, 1); | ||
</ | </pre> | ||
Recording statistics is useless unless you can read the values back. This is where the concept of a <code>Recorder</code> comes in. | Recording statistics is useless unless you can read the values back. This is where the concept of a <code>Recorder</code> comes in. A recorder is |
Revision as of 15:01, 15 October 2013
What is it?
LLTrace is our system for capturing realtime statistic related to viewer performance and behavior and (optionally) associating those metrics with certain actions or periods of time.
Most of the statistics that the viewer captures go through LLTrace. Examples include:
- Frame rate
- Bandwidth
- Ping time
- Object/Texture cache hit rate
In addition, LLTrace is used to capture detailed memory usage breakdown and time spent in various functions. By design, all of these metrics are available for run-time queries from the code, enabling detailed logging, in-client profiling, statistics reporting, and even self-tuning components and algorithms.
Usage
First, you need to declare a statistic that you are going to track. For example, let's say you want to create a pedometer for your avatar. If you want to know how many footsteps your avatar takes, you would declare a *count* statistic for footsteps like this:
static LLTrace::CountStatHandle<> sFootSteps ("footstepcount", "Number of footsteps I've taken");
This declares a handle to this particular statistic that you will use in all future reads/writes of that stat. This object needs to be a global/static variable so that when we start running SL code, we have an accurate count of how many statistics we have. Support for dynamically adding/removing stats is under consideration for a future release. The template parameter is used to specify the type of value the statistic is stored as. Here we are using the default, which is a double precision floating point value. All values are stored as double precision floats under the hood, so don't bother optimizing for integers, etc. The first parameter is the name of the stat, used for tagging in output and runtime lookup. The second parameter is a documentation string describing what this statistic means.
Next, you can record your data. For a count-like statistic, this is done through the add method:
// I took a step add(sFootSteps, 1);
Recording statistics is useless unless you can read the values back. This is where the concept of a Recorder
comes in. A recorder is