static
Class YAHOO.tool.Profiler
Profiles functions in JavaScript.
Properties
_container
- private static Object
Container object on which to put the original unprofiled methods.
_report
- private static Object
Call information for functions.
Methods
private
static
Void
_saveData
(
name
,
duration
)
Called when a method ends execution. Marks the start and end time of the
method so it can calculate how long the function took to execute. Also
updates min/max/avg calculations for the function.
- Parameters:
-
name
<String>
The name of the function to mark as stopped.
-
duration
<int>
The number of milliseconds it took the function to
execute.
- Returns:
Void
static
float
getAverage
(
name
)
Returns the average amount of time (in milliseconds) that the function
with the given name takes to execute.
- Parameters:
-
name
<String>
The name of the function whose data should be returned.
If an object type method, it should be 'constructor.prototype.methodName';
a normal object method would just be 'object.methodName'.
- Returns:
float
- The average time it takes the function to execute.
static
int
getCallCount
(
name
)
Returns the number of times that the given function has been called.
- Parameters:
-
name
<String>
The name of the function whose data should be returned.
- Returns:
int
- The number of times the function was called.
static
Object
getFullReport
(
)
Returns an object containing profiling data for all of the functions
that were profiled. The object has an entry for each function and
returns all information (min, max, average, calls, etc.) for each
function.
- Returns:
Object
- An object containing all profile data.
static
Object
getFunctionReport
(
)
Returns an object containing profiling data for a single function.
The object has an entry for min, max, avg, calls, and points).
- Returns:
Object
- An object containing profile data for a given function.
float
getMax
(
name
)
Returns the maximum amount of time (in milliseconds) that the function
with the given name takes to execute.
- Parameters:
-
name
<String>
The name of the function whose data should be returned.
If an object type method, it should be 'constructor.prototype.methodName';
a normal object method would just be 'object.methodName'.
- Returns:
float
- The maximum time it takes the function to execute.
float
getMin
(
name
)
Returns the minimum amount of time (in milliseconds) that the function
with the given name takes to execute.
- Parameters:
-
name
<String>
The name of the function whose data should be returned.
If an object type method, it should be 'constructor.prototype.methodName';
a normal object method would just be 'object.methodName'.
- Returns:
float
- The minimum time it takes the function to execute.
static
Void
registerConstructor
(
name
,
owner
)
Sets up a constructor for profiling, including all properties and methods on the prototype.
- Parameters:
-
name
<string>
The fully-qualified name of the function including namespace information.
-
owner
<Object>
(Optional) The object that owns the function (namespace or containing object).
- Returns:
Void
Void
registerFunction
(
name
,
owner
)
Sets up a function for profiling. It essentially overwrites the function with one
that has instrumentation data. This method also creates an entry for the function
in the profile report. The original function is stored on the _container object.
- Parameters:
-
name
<String>
The full name of the function including namespacing. This
is the name of the function that is stored in the report.
-
owner
<Object>
(Optional) The object that owns the function. If the function
isn't global then this argument is required. This could be the namespace that
the function belongs to, such as YAHOO.util.Dom, or the object on which it's
a method.
- Returns:
Void
static
Void
registerObject
(
name
,
owner
,
recurse
)
Sets up an object for profiling. It takes the object and looks for functions.
When a function is found, registerMethod() is called on it. If set to recrusive
mode, it will also setup objects found inside of this object for profiling,
using the same methodology.
- Parameters:
-
name
<String>
The name of the object to profile (shows up in report).
-
owner
<Object>
(Optional) The object represented by the name.
-
recurse
<Boolean>
(Optional) Determines if subobject methods are also profiled.
- Returns:
Void
Void
unregisterFunction
(
name
)
Removes a constructor function from profiling. Reverses the registerConstructor() method.
- Parameters:
-
name
<String>
The full name of the function including namespacing. This
is the name of the function that is stored in the report.
- Returns:
Void
static
Void
unregisterObject
(
name
,
recurse
)
Unregisters an object for profiling. It takes the object and looks for functions.
When a function is found, unregisterMethod() is called on it. If set to recrusive
mode, it will also unregister objects found inside of this object,
using the same methodology.
- Parameters:
-
name
<String>
The name of the object to unregister.
-
recurse
<Boolean>
(Optional) Determines if subobject methods should also be
unregistered.
- Returns:
Void