22
edits
No edit summary |
No edit summary |
||
| Line 7: | Line 7: | ||
== The Profiler object == | == The Profiler object == | ||
There will be a global <tt>Profiler</tt> object available to instantiate to begin profiling | There will be a global <tt>Profiler</tt> object available to instantiate to begin profiling the runtime in which the profiler was created in. The <tt>Profiler</tt> object has the following methods: | ||
<dl> | <dl> | ||
| Line 13: | Line 13: | ||
<dd>The constructor takes no arguments | <dd>The constructor takes no arguments | ||
<dt>start( | <dt>start([sample_rate, [max_samples]]) | ||
<dd>Begins profiling. All arguments are optional. If | <dd>Begins profiling. All arguments are optional. If the runtime is already being profiled an error is thrown. | ||
The sample rate is the time between samples of the call stack specified in microseconds (defaults to 1000 = 1ms). The sample rate is mostly a guideline as the platform being run might not guarantee the granularity of timing. Samples will not happen more frequently than the specified rate, but may occur more infrequently. | The sample rate is the time between samples of the call stack specified in microseconds (defaults to 1000 = 1ms). The sample rate is mostly a guideline as the platform being run might not guarantee the granularity of timing. Samples will not happen more frequently than the specified rate, but may occur more infrequently. | ||
| Line 21: | Line 21: | ||
If some other Profiler object is profiling the specified runtime, then an error is thrown if the sample rate or maximum sample count is different. Eventually a call to stopProfiling() must be paired with this call to cease data collection. | If some other Profiler object is profiling the specified runtime, then an error is thrown if the sample rate or maximum sample count is different. Eventually a call to stopProfiling() must be paired with this call to cease data collection. | ||
<dt>isProfiling( | <dt>isProfiling() | ||
<dd>Returns whether profiling is turned on for the | <dd>Returns whether profiling is turned on for the runtime | ||
<dt>frame() | <dt>frame() | ||
<dd>Fetches an object to represent the current stack trace to be later returned via results(). This object can have any properties attached to it and will persist across different invocations of frame() so long as the same backtrace is present each time. All information specified here will later be available via results() with the full backtrace listed. By default this returns an empty object with no properties. If the current runtime is not being profiled, then an error is thrown. | <dd>Fetches an object to represent the current stack trace to be later returned via results(). This object can have any properties attached to it and will persist across different invocations of frame() so long as the same backtrace is present each time. All information specified here will later be available via results() with the full backtrace listed. By default this returns an empty object with no properties. If the current runtime is not being profiled, then an error is thrown. | ||
<dt>results( | <dt>results() | ||
<dd>Returns all profile information for the | <dd>Returns all profile information for the runtime. The data returned is all that is collected between the last invocation of reset() and all the profile data. | ||
<dt>reset( | <dt>reset() | ||
<dd>Resets all information known about the | <dd>Resets all information known about the runtime. This includes samples and also frame() information. Throws an error if the runtime in question isn't being profiled. | ||
<dt>stop( | <dt>stop() | ||
<dd>Ceases profiling on the | <dd>Ceases profiling on the runtime. If the runtime in question isn't being profiled, an error is thrown. | ||
</dl> | </dl> | ||
edits