@UiThread public class ProfilerController extends Object
profilerController.addMarker("marker name")
.
Or if you want to provide more information, you can use
profilerController.addMarker("marker name", "extra information")
If you want to add a profiler marker with a duration (with start and end time)
you can use it like this:
Double startTime = profilerController.getProfilerTime();
...some code you want to measure...
profilerController.addMarker("name", startTime);
Or you can capture start and end time in somewhere, then add the marker in somewhere
else:
Double startTime = profilerController.getProfilerTime();
...some code you want to measure (or end time can be collected in a callback)...
Double endTime = profilerController.getProfilerTime();
...somewhere else in the codebase...
profilerController.addMarker("name", startTime, endTime);
Here's an addMarker
example with all the possible parameters:
Double startTime = profilerController.getProfilerTime();
...some code you want to measure...
Double endTime = profilerController.getProfilerTime();
...somewhere else in the codebase...
profilerController.addMarker("name", startTime, endTime, "extra information");
isProfilerActive
method is handy when you want to get more information to
add inside the marker, but you think it's going to be computationally heavy (and useless)
when profiler is not running:
Double startTime = profilerController.getProfilerTime();
...some code you want to measure...
if (profilerController.isProfilerActive()) {
String info = aFunctionYouDoNotWantToCallWhenProfilerIsNotActive();
profilerController.addMarker("name", startTime, info);
}
FIXME(bug 1618560): Currently only works in the main thread.Constructor and Description |
---|
ProfilerController() |
Modifier and Type | Method and Description |
---|---|
void |
addMarker(String aMarkerName)
Add a profiler marker to Gecko Profiler with the given arguments.
|
void |
addMarker(String aMarkerName,
Double aStartTime)
Add a profiler marker to Gecko Profiler with the given arguments.
|
void |
addMarker(String aMarkerName,
Double aStartTime,
Double aEndTime,
String aText)
Add a profiler marker to Gecko Profiler with the given arguments.
|
void |
addMarker(String aMarkerName,
Double aStartTime,
String aText)
Add a profiler marker to Gecko Profiler with the given arguments.
|
void |
addMarker(String aMarkerName,
String aText)
Add a profiler marker to Gecko Profiler with the given arguments.
|
Double |
getProfilerTime()
Get the profiler time to be able to mark the start of the marker events.
|
boolean |
isProfilerActive()
Returns true if profiler is active and it's allowed the add markers.
|
public boolean isProfilerActive()
@Nullable public Double getProfilerTime()
Double startTime = profilerController.getProfilerTime();
...some code you want to measure...
profilerController.addMarker("name", startTime);
public void addMarker(@NonNull String aMarkerName, @Nullable Double aStartTime, @Nullable Double aEndTime, @Nullable String aText)
aMarkerName
- Name of the event as a string.aStartTime
- Start time as Double. It can be null if you want to mark a point of time.aEndTime
- End time as Double. If it's null, this function implicitly gets the end time.aText
- An optional string field for more information about the marker.public void addMarker(@NonNull String aMarkerName, @Nullable Double aStartTime, @Nullable String aText)
addMarker(String, Double, Double, String)
for convenience.aMarkerName
- Name of the event as a string.aStartTime
- Start time as Double. It can be null if you want to mark a point of time.aText
- An optional string field for more information about the marker.public void addMarker(@NonNull String aMarkerName, @Nullable Double aStartTime)
addMarker(String, Double, Double, String)
for convenience.aMarkerName
- Name of the event as a string.aStartTime
- Start time as Double. It can be null if you want to mark a point of time.public void addMarker(@NonNull String aMarkerName, @Nullable String aText)
addMarker(String, Double, Double, String)
for convenience.aMarkerName
- Name of the event as a string.aText
- An optional string field for more information about the marker.public void addMarker(@NonNull String aMarkerName)
addMarker(String, Double, Double, String)
for convenience.aMarkerName
- Name of the event as a string.