LLTrace

From Second Life Wiki
Revision as of 15:58, 15 October 2013 by Richard Linden (talk | contribs) (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…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.

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.