Commit 01ca34cd authored by Andrew Wilson's avatar Andrew Wilson Committed by GitHub

Add profiling for building and painting. (#6652)

parent 57be9598
...@@ -76,6 +76,13 @@ bool debugPrintMarkNeedsLayoutStacks = false; ...@@ -76,6 +76,13 @@ bool debugPrintMarkNeedsLayoutStacks = false;
/// Check the intrinsic sizes of each [RenderBox] during layout. /// Check the intrinsic sizes of each [RenderBox] during layout.
bool debugCheckIntrinsicSizes = false; 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]. /// Returns a list of strings representing the given transform in a format useful for [RenderObject.debugFillDescription].
List<String> debugDescribeTransform(Matrix4 transform) { List<String> debugDescribeTransform(Matrix4 transform) {
List<String> matrix = transform.toString().split('\n').map((String s) => ' $s').toList(); List<String> matrix = transform.toString().split('\n').map((String s) => ' $s').toList();
......
...@@ -95,12 +95,24 @@ class PaintingContext { ...@@ -95,12 +95,24 @@ class PaintingContext {
/// into the layer subtree associated with this painting context. Otherwise, /// into the layer subtree associated with this painting context. Otherwise,
/// the child will be painted into the current PictureLayer for this context. /// the child will be painted into the current PictureLayer for this context.
void paintChild(RenderObject child, Offset offset) { void paintChild(RenderObject child, Offset offset) {
assert(() {
if (debugProfilePaintsEnabled)
Timeline.startSync('${child.runtimeType}');
return true;
});
if (child.isRepaintBoundary) { if (child.isRepaintBoundary) {
_stopRecordingIfNeeded(); _stopRecordingIfNeeded();
_compositeChild(child, offset); _compositeChild(child, offset);
} else { } else {
child._paintWithContext(this, offset); child._paintWithContext(this, offset);
} }
assert(() {
if (debugProfilePaintsEnabled)
Timeline.finishSync();
return true;
});
} }
void _compositeChild(RenderObject child, Offset offset) { void _compositeChild(RenderObject child, Offset offset) {
......
...@@ -48,6 +48,12 @@ bool debugPrintScheduleBuildForStacks = false; ...@@ -48,6 +48,12 @@ bool debugPrintScheduleBuildForStacks = false;
/// This can help track down framework bugs relating to the [GlobalKey] logic. /// This can help track down framework bugs relating to the [GlobalKey] logic.
bool debugPrintGlobalKeyedWidgetLifecycle = false; 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) { Key _firstNonUniqueKey(Iterable<Widget> widgets) {
Set<Key> keySet = new HashSet<Key>(); Set<Key> keySet = new HashSet<Key>();
for (Widget widget in widgets) { for (Widget widget in widgets) {
......
...@@ -2846,6 +2846,12 @@ abstract class ComponentElement extends BuildableElement { ...@@ -2846,6 +2846,12 @@ abstract class ComponentElement extends BuildableElement {
/// [rebuild] when the element needs updating. /// [rebuild] when the element needs updating.
@override @override
void performRebuild() { void performRebuild() {
assert(() {
if (debugProfileBuildsEnabled)
Timeline.startSync('${widget.runtimeType}');
return true;
});
assert(_debugSetAllowIgnoredCallsToMarkNeedsBuild(true)); assert(_debugSetAllowIgnoredCallsToMarkNeedsBuild(true));
Widget built; Widget built;
try { try {
...@@ -2868,6 +2874,12 @@ abstract class ComponentElement extends BuildableElement { ...@@ -2868,6 +2874,12 @@ abstract class ComponentElement extends BuildableElement {
built = new ErrorWidget(e); built = new ErrorWidget(e);
_child = updateChild(null, built, slot); _child = updateChild(null, built, slot);
} }
assert(() {
if (debugProfileBuildsEnabled)
Timeline.finishSync();
return true;
});
} }
@override @override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment