Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: sky/sdk/lib/widgets/widget.dart

Issue 1216973005: Turn off the code that is forcing stocksapp to build 50 times a second, and change the code that tr… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'dart:mirrors'; 7 import 'dart:mirrors';
8 import 'dart:sky' as sky; 8 import 'dart:sky' as sky;
9 9
10 import '../base/hit_test.dart'; 10 import '../base/hit_test.dart';
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 } 505 }
506 506
507 Widget build(); 507 Widget build();
508 508
509 } 509 }
510 510
511 Set<Component> _dirtyComponents = new Set<Component>(); 511 Set<Component> _dirtyComponents = new Set<Component>();
512 bool _buildScheduled = false; 512 bool _buildScheduled = false;
513 bool _inRenderDirtyComponents = false; 513 bool _inRenderDirtyComponents = false;
514 514
515 List<int> _debugFrameTimes = <int>[];
516
515 void _buildDirtyComponents() { 517 void _buildDirtyComponents() {
516 Stopwatch sw; 518 Stopwatch sw;
517 if (_shouldLogRenderDuration) 519 if (_shouldLogRenderDuration)
518 sw = new Stopwatch()..start(); 520 sw = new Stopwatch()..start();
519 521
520 try { 522 try {
521 sky.tracing.begin('Widgets._buildDirtyComponents'); 523 sky.tracing.begin('Widgets._buildDirtyComponents');
522 _inRenderDirtyComponents = true; 524 _inRenderDirtyComponents = true;
523 525
524 List<Component> sortedDirtyComponents = _dirtyComponents.toList(); 526 List<Component> sortedDirtyComponents = _dirtyComponents.toList();
525 sortedDirtyComponents.sort((Component a, Component b) => a._order - b._order ); 527 sortedDirtyComponents.sort((Component a, Component b) => a._order - b._order );
526 for (var comp in sortedDirtyComponents) { 528 for (var comp in sortedDirtyComponents) {
527 comp._buildIfDirty(); 529 comp._buildIfDirty();
528 } 530 }
529 531
530 _dirtyComponents.clear(); 532 _dirtyComponents.clear();
531 _buildScheduled = false; 533 _buildScheduled = false;
532 } finally { 534 } finally {
533 _inRenderDirtyComponents = false; 535 _inRenderDirtyComponents = false;
534 sky.tracing.end('Widgets._buildDirtyComponents'); 536 sky.tracing.end('Widgets._buildDirtyComponents');
535 } 537 }
536 538
537 Widget._notifyMountStatusChanged(); 539 Widget._notifyMountStatusChanged();
538 540
539 if (_shouldLogRenderDuration) { 541 if (_shouldLogRenderDuration) {
540 sw.stop(); 542 sw.stop();
541 print('Render took ${sw.elapsedMicroseconds} microseconds'); 543 _debugFrameTimes.add(sw.elapsedMicroseconds);
544 if (_debugFrameTimes.length >= 1000) {
545 _debugFrameTimes.sort();
546 const int i = 99;
547 print('_buildDirtyComponents: ${i+1}th fastest frame out of the last ${_de bugFrameTimes.length}: ${_debugFrameTimes[i]} microseconds');
548 _debugFrameTimes.clear();
549 }
abarth-chromium 2015/06/29 22:39:57 Did you mean to check this in?
542 } 550 }
543 } 551 }
544 552
545 void _scheduleComponentForRender(Component c) { 553 void _scheduleComponentForRender(Component c) {
546 assert(!_inRenderDirtyComponents); 554 assert(!_inRenderDirtyComponents);
547 _dirtyComponents.add(c); 555 _dirtyComponents.add(c);
548 556
549 if (!_buildScheduled) { 557 if (!_buildScheduled) {
550 _buildScheduled = true; 558 _buildScheduled = true;
551 new Future.microtask(_buildDirtyComponents); 559 new Future.microtask(_buildDirtyComponents);
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 if (root.parent == null) { 1013 if (root.parent == null) {
1006 // we haven't attached it yet 1014 // we haven't attached it yet
1007 assert(_container.child == null); 1015 assert(_container.child == null);
1008 _container.child = root; 1016 _container.child = root;
1009 } 1017 }
1010 assert(root.parent == _container); 1018 assert(root.parent == _container);
1011 } 1019 }
1012 1020
1013 Widget build() => builder(); 1021 Widget build() => builder();
1014 } 1022 }
OLDNEW
« sky/sdk/example/stocks/lib/main.dart ('K') | « sky/sdk/example/stocks/lib/main.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698