This example shows using the Profiler on all methods in an object. It uses the
as the object to be profiled.
Keep an eye on the Logger console at right to see the profiling information being reported.
To illustrate using the Profiler on objects, the
YAHOO.util.Dom object is registered for profiling. This means
that all of the methods on the object are being profiled. The two methods being called explicity are
addClass(), although the Profiler will show that these methods use other methods on
illustrate their use, a number of demo elements are added to the markup:
The button is used to run the example. The function being called when the button is clicked is assigned using the
YUI Event Utility's
The function begins be registering
YAHOO.util.Dom with the Profiler. Note that since this object exists in the
global scope, only one argument is necessary for
registerObject(). Then, the
addClass() methods are called. After that, the full report is returned and the object is unregistered. The last
step is to output all of the information that was collected. Even though there's only two methods called explicitly in this example,
the profiled data indicates that several other methods on
YAHOO.util.Dom were called internally to accomplish the
All YUI 2.x users should review the YUI 2.8.2 security bulletin, which discusses a vulnerability present in YUI 2.4.0-2.8.1.