DevTools/OperationInstrument: Difference between revisions

Jump to navigation Jump to search
m
 
(2 intermediate revisions by one other user not shown)
Line 33: Line 33:
The easiest way to trace Gecko events/tasks with start and end timeline markers is to use the '''<code>mozilla::AutoTimelineMarker</code>''' RAII class. It automatically adds the start marker on construction, and adds the end marker on destruction. Don't worry too much about potential performance impact! It only actually adds the markers when the given docshell is being observed by a timeline consumer, so essentially nothing will happen if a tool to inspect those markers isn't specifically open.
The easiest way to trace Gecko events/tasks with start and end timeline markers is to use the '''<code>mozilla::AutoTimelineMarker</code>''' RAII class. It automatically adds the start marker on construction, and adds the end marker on destruction. Don't worry too much about potential performance impact! It only actually adds the markers when the given docshell is being observed by a timeline consumer, so essentially nothing will happen if a tool to inspect those markers isn't specifically open.


This class may be used on the main thread only and pointer to a docshell is necessary. If the docshell is a nullptr, nothing happens and this operation fails silently.
This class may only be used on the main thread, and pointer to a docshell is necessary. If the docshell is a nullptr, nothing happens and this operation fails silently.


Example:
Example:
Line 47: Line 47:


===== Using ''<code>TimelineConsumers</code>'' =====  
===== Using ''<code>TimelineConsumers</code>'' =====  
A few static methods exist on the [https://dxr.mozilla.org/mozilla-central/source/docshell/base/timeline/TimelineConsumers.h?from=TimelineConsumers <code>TimelineConsumers</code>] class, like ''<code>AddMarkerForDocShell</code>'', ''<code>AddMarkerToDocShellsList</code>'', ''<code>AddMarkerToAllObservedDocShells</code>'' that give you fine grained control over creating the markers and what meta-data is attached to them.
A few static methods exist on the [https://dxr.mozilla.org/mozilla-central/source/docshell/base/timeline/TimelineConsumers.h?from=TimelineConsumers <code>TimelineConsumers</code>] class, like ''<code>AddMarkerForDocShell</code>'', ''<code>AddMarkerForDocShellsList</code>'', ''<code>AddMarkerForAllObservedDocShells</code>'' that give you fine grained control over creating the markers and what meta-data is attached to them.


Example:
Example:
Line 55: Line 55:
== 2. Telling the DevTools Frontend About the New Markers ==
== 2. Telling the DevTools Frontend About the New Markers ==


To get your new markers displayed in the performance tool's UI, edit the configuration data in '''<code>browser/devtools/performance/modules/markers.js</code>'''.
To get your new markers displayed in the performance tool's UI, edit the configuration data in '''<code>devtools/client/performance/modules/markers.js</code>'''.


Add a property to the '''<code>TIMELINE_BLUEPRINT</code>''' object. The property key should be the <code>const char *</code> literal that you added in step 1 ("Parse HTML" in our example). The new property should be an object with the following properties:
Add a property to the '''<code>TIMELINE_BLUEPRINT</code>''' object. The property key should be the <code>const char *</code> literal that you added in step 1 ("Parse HTML" in our example). The new property should be an object with the following properties:
Confirmed users
125

edits

Navigation menu