Add profiling for building and painting. (#6652)
This commit is contained in:
@@ -76,6 +76,13 @@ bool debugPrintMarkNeedsLayoutStacks = false;
|
||||
/// Check the intrinsic sizes of each [RenderBox] during layout.
|
||||
bool debugCheckIntrinsicSizes = false;
|
||||
|
||||
/// Adds [Timeline] events for every RenderObject painted.
|
||||
///
|
||||
/// For details on how to use [Timeline] events in the Dart Observatory to
|
||||
/// optimize your app, see https://fuchsia.googlesource.com/sysui/+/master/docs/performance.md
|
||||
bool debugProfilePaintsEnabled = false;
|
||||
|
||||
|
||||
/// Returns a list of strings representing the given transform in a format useful for [RenderObject.debugFillDescription].
|
||||
List<String> debugDescribeTransform(Matrix4 transform) {
|
||||
List<String> matrix = transform.toString().split('\n').map((String s) => ' $s').toList();
|
||||
|
||||
@@ -95,12 +95,24 @@ class PaintingContext {
|
||||
/// into the layer subtree associated with this painting context. Otherwise,
|
||||
/// the child will be painted into the current PictureLayer for this context.
|
||||
void paintChild(RenderObject child, Offset offset) {
|
||||
assert(() {
|
||||
if (debugProfilePaintsEnabled)
|
||||
Timeline.startSync('${child.runtimeType}');
|
||||
return true;
|
||||
});
|
||||
|
||||
if (child.isRepaintBoundary) {
|
||||
_stopRecordingIfNeeded();
|
||||
_compositeChild(child, offset);
|
||||
} else {
|
||||
child._paintWithContext(this, offset);
|
||||
}
|
||||
|
||||
assert(() {
|
||||
if (debugProfilePaintsEnabled)
|
||||
Timeline.finishSync();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void _compositeChild(RenderObject child, Offset offset) {
|
||||
|
||||
@@ -48,6 +48,12 @@ bool debugPrintScheduleBuildForStacks = false;
|
||||
/// This can help track down framework bugs relating to the [GlobalKey] logic.
|
||||
bool debugPrintGlobalKeyedWidgetLifecycle = false;
|
||||
|
||||
/// Adds [Timeline] events for every Widget built.
|
||||
///
|
||||
/// For details on how to use [Timeline] events in the Dart Observatory to
|
||||
/// optimize your app, see https://fuchsia.googlesource.com/sysui/+/master/docs/performance.md
|
||||
bool debugProfileBuildsEnabled = false;
|
||||
|
||||
Key _firstNonUniqueKey(Iterable<Widget> widgets) {
|
||||
Set<Key> keySet = new HashSet<Key>();
|
||||
for (Widget widget in widgets) {
|
||||
|
||||
@@ -2846,6 +2846,12 @@ abstract class ComponentElement extends BuildableElement {
|
||||
/// [rebuild] when the element needs updating.
|
||||
@override
|
||||
void performRebuild() {
|
||||
assert(() {
|
||||
if (debugProfileBuildsEnabled)
|
||||
Timeline.startSync('${widget.runtimeType}');
|
||||
return true;
|
||||
});
|
||||
|
||||
assert(_debugSetAllowIgnoredCallsToMarkNeedsBuild(true));
|
||||
Widget built;
|
||||
try {
|
||||
@@ -2868,6 +2874,12 @@ abstract class ComponentElement extends BuildableElement {
|
||||
built = new ErrorWidget(e);
|
||||
_child = updateChild(null, built, slot);
|
||||
}
|
||||
|
||||
assert(() {
|
||||
if (debugProfileBuildsEnabled)
|
||||
Timeline.finishSync();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user