This example shows using the Profiler on all methods in an object. It uses the YAHOO.util.Dom
object
as the object to be profiled.
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 getElementsByClassName()
and addClass()
, although the Profiler will show that these methods use other methods on YAHOO.util.Dom
. To
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 on()
method:
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 getElementsByClassName()
and 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
tasks.
Copyright © 2007 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings