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

Unified Diff: sky/framework/fn.dart

Issue 982073002: fn.dart shouldn't spam the log (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/fn.dart
diff --git a/sky/framework/fn.dart b/sky/framework/fn.dart
index cfd25775265a673f5aa94577ae6212a1c2c8ca6b..27b44b2c5950442b954506bd68a24479166d834e 100644
--- a/sky/framework/fn.dart
+++ b/sky/framework/fn.dart
@@ -9,23 +9,19 @@ import 'dart:collection';
import 'dart:sky' as sky;
import 'reflect.dart' as reflect;
-bool _checkedMode;
-
-bool _debugWarnings() {
+bool _initIsInCheckedMode() {
void testFn(double i) {}
-
- if (_checkedMode == null) {
- _checkedMode = false;
- try {
- testFn('not a double');
- } catch (ex) {
- _checkedMode = true;
- }
+ try {
+ testFn('not a double');
+ } catch (ex) {
+ return true;
}
-
- return _checkedMode;
+ return false;
}
+final bool _isInCheckedMode = _initIsInCheckedMode();
+final bool _shouldLogRenderDuration = false;
+
class EventHandler {
final String type;
final sky.EventListener listener;
@@ -152,7 +148,7 @@ abstract class Element extends Node {
_className = style == null ? '': style._className;
_children = children == null ? _emptyList : children;
- if (_debugWarnings()) {
+ if (_isInCheckedMode) {
_debugReportDuplicateIds();
}
}
@@ -516,8 +512,10 @@ void _renderDirtyComponents() {
_dirtyComponents.clear();
_renderScheduled = false;
+
sw.stop();
- print("Render took ${sw.elapsedMicroseconds} microseconds");
+ if (_shouldLogRenderDuration)
+ print("Render took ${sw.elapsedMicroseconds} microseconds");
}
void _scheduleComponentForRender(Component c) {
@@ -646,18 +644,19 @@ abstract class Component extends Node {
abstract class App extends Component {
sky.Node _host = null;
- App()
- : super(stateful: true) {
-
+ App() : super(stateful: true) {
_host = sky.document.createElement('div');
sky.document.appendChild(_host);
new Future.microtask(() {
Stopwatch sw = new Stopwatch()..start();
+
_sync(null, _host, null);
assert(_root is sky.Node);
+
sw.stop();
- print("Initial render: ${sw.elapsedMicroseconds} microseconds");
+ if (_shouldLogRenderDuration)
+ print("Initial render: ${sw.elapsedMicroseconds} microseconds");
});
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698