22
edits
No edit summary |
No edit summary |
||
| Line 25: | Line 25: | ||
<dt>results() | <dt>results() | ||
<dd>Returns all profile information gathered. The data returned is all that is collected between the last invocation of reset() and all the sample data. | <dd>Returns all profile information gathered. The data returned is all that is collected between the last invocation of reset() and all the sample data. | ||
<dt>samples() | |||
<dd>Returns all profiling samples gathered. The data returned is all that is collected between the last invocation of reset() and now. | |||
<dt>reset() | <dt>reset() | ||
<dd>Resets all information that is stored. This includes samples and also frame() information. | <dd>Resets all information that is stored. This includes samples and also frame() information. | ||
| Line 134: | Line 136: | ||
<dt>selfCount | <dt>selfCount | ||
<dd>This is an integer value like "samples," but instead only counts the time spent in the function itself. When a sample is taken and a function is currently running (it's the top of the stack), it's selfCount is increased. | <dd>This is an integer value like "samples," but instead only counts the time spent in the function itself. When a sample is taken and a function is currently running (it's the top of the stack), it's selfCount is increased. | ||
</dl> | |||
=== The return of <tt>.samples()</tt> === | |||
The samples() method of a Profiler returns a list of sample objects which describe a sample taken at a particular time. Each object has the following structure: | |||
{ | |||
micros: 100, | |||
isGc: false, | |||
weight: 2, | |||
stack: [ | |||
{ | |||
function: { line: 20, file: '...' }, | |||
site: { line: 30, file: '...' } | |||
}, | |||
... | |||
] | |||
} | |||
Each sample's field are as follows: | |||
<dl> | |||
<dt>micros | |||
<dd>This is the time at which the sample was taken (in microseconds). | |||
<dt>isGc | |||
<dd>This is a boolean describing whether this sample was purely a GC sample. If true, then the stack has no entries. If false, then the stack has at least one entry. | |||
<dt>weight | |||
<dd>Due to the way sampling is currently implemented, time spent in native C++ functions prevent samples from being taken. For this reason, the time is attributed to the next sample. Hence this weight indicates how many samples were deferred to this stack trace. | |||
<dt>stack | |||
<dd>If isGc is false, then this will be a non-empty array with the stack trace at the time of the sample. The first function is the top of the stack and each subsequent function called the previous function. The 'function' field describes where the function was defined, and the 'site' field describes where the function is currently executing. | |||
</dl> | </dl> | ||
edits