@@ -2173,13 +2173,13 @@ class _ConstraintRenderBox extends RenderBox
21732173
21742174 @override
21752175 void performLayout () {
2176- int startTime = 0 ;
2176+ Stopwatch ? stopwatch ;
21772177 if (_releasePrintLayoutTime && kReleaseMode) {
2178- startTime = DateTime . now ().millisecondsSinceEpoch ;
2178+ stopwatch = Stopwatch ().. start () ;
21792179 }
21802180 assert (() {
21812181 if (_debugPrintLayoutTime) {
2182- startTime = DateTime . now ().millisecondsSinceEpoch ;
2182+ stopwatch = Stopwatch ().. start () ;
21832183 }
21842184 return true ;
21852185 }());
@@ -2263,19 +2263,12 @@ class _ConstraintRenderBox extends RenderBox
22632263
22642264 _layoutByConstrainedNodeTrees ();
22652265
2266- if (_releasePrintLayoutTime && kReleaseMode ) {
2267- layoutTimeUsage.add (DateTime . now ().millisecondsSinceEpoch - startTime );
2266+ if (stopwatch != null ) {
2267+ layoutTimeUsage.add (stopwatch ! .elapsedMicroseconds );
22682268 if (layoutTimeUsage.length > maxTimeUsage) {
22692269 layoutTimeUsage.removeFirst ();
22702270 }
22712271 }
2272- assert (() {
2273- layoutTimeUsage.add (DateTime .now ().millisecondsSinceEpoch - startTime);
2274- if (layoutTimeUsage.length > maxTimeUsage) {
2275- layoutTimeUsage.removeFirst ();
2276- }
2277- return true ;
2278- }());
22792272 }
22802273
22812274 static double _getLeftInsets (
@@ -2857,13 +2850,13 @@ class _ConstraintRenderBox extends RenderBox
28572850 PaintingContext context,
28582851 Offset offset,
28592852 ) {
2860- int startTime = 0 ;
2853+ Stopwatch ? stopwatch ;
28612854 if (_releasePrintLayoutTime && kReleaseMode) {
2862- startTime = DateTime . now ().millisecondsSinceEpoch ;
2855+ stopwatch = Stopwatch ().. start () ;
28632856 }
28642857 assert (() {
28652858 if (_debugPrintLayoutTime) {
2866- startTime = DateTime . now ().millisecondsSinceEpoch ;
2859+ stopwatch = Stopwatch ().. start () ;
28672860 }
28682861 return true ;
28692862 }());
@@ -2992,23 +2985,13 @@ class _ConstraintRenderBox extends RenderBox
29922985 return true ;
29932986 }());
29942987
2995- if (_releasePrintLayoutTime && kReleaseMode ) {
2996- paintTimeUsage.add (DateTime . now ().millisecondsSinceEpoch - startTime );
2988+ if (stopwatch != null ) {
2989+ paintTimeUsage.add (stopwatch ! .elapsedMicroseconds );
29972990 if (paintTimeUsage.length > maxTimeUsage) {
29982991 paintTimeUsage.removeFirst ();
29992992 }
30002993 _debugShowPerformance (context, offset);
30012994 }
3002- assert (() {
3003- if (_debugPrintLayoutTime) {
3004- paintTimeUsage.add (DateTime .now ().millisecondsSinceEpoch - startTime);
3005- if (paintTimeUsage.length > maxTimeUsage) {
3006- paintTimeUsage.removeFirst ();
3007- }
3008- _debugShowPerformance (context, offset);
3009- }
3010- return true ;
3011- }());
30122995 }
30132996
30142997 void _debugShowPerformance (
@@ -3033,7 +3016,7 @@ class _ConstraintRenderBox extends RenderBox
30333016 color: Colors .green,
30343017 ));
30353018 }
3036- paragraphBuilder.addText ("layout $layoutTime ms " );
3019+ paragraphBuilder.addText ("layout $layoutTime us " );
30373020 ui.Paragraph paragraph = paragraphBuilder.build ();
30383021 paragraph.layout (const ui.ParagraphConstraints (
30393022 width: 80 ,
@@ -3061,7 +3044,7 @@ class _ConstraintRenderBox extends RenderBox
30613044 color: Colors .green,
30623045 ));
30633046 }
3064- paragraphBuilder.addText ("paint $paintTime ms " );
3047+ paragraphBuilder.addText ("paint $paintTime us " );
30653048 ui.Paragraph paragraph = paragraphBuilder.build ();
30663049 paragraph.layout (const ui.ParagraphConstraints (
30673050 width: 80 ,
0 commit comments