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

Unified Diff: runtime/bin/vmstats/vmstats.dart

Issue 12377099: Added support for "bin-ified" vmstats web app source files (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Made model data immutable Created 7 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
Index: runtime/bin/vmstats/vmstats.dart
===================================================================
--- runtime/bin/vmstats/vmstats.dart (revision 0)
+++ runtime/bin/vmstats/vmstats.dart (revision 0)
@@ -0,0 +1,59 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library dart.vmstats;
+
+import 'dart:async';
+import 'dart:html';
+import 'dart:json' as JSON;
+
+part 'bargraph.dart';
+part 'isolate_list.dart';
+part 'models.dart';
+
+BarGraph _graph;
+IsolateList _isolateList;
+DivElement _statusText;
+IsolateListModel _isolates;
+Timer _updater;
+
+final int _POLL_INTERVAL = 1000;
srdjan 2013/03/06 01:14:37 It would be good to include unit in the name, e.g.
Tom Ball 2013/03/06 17:47:17 Done.
+
+void main() {
+ DivElement dashBoard = query('#dashboard');
+ CanvasElement canvas = query('#graph');
+ var elements = [ new Element("Old Space", "#97FFFF"),
+ new Element("New Space", "#00EE76")];
+ _graph = new BarGraph(canvas, elements);
+ UListElement isolateListElement = query('#isolateList');
+ _isolateList = new IsolateList(isolateListElement);
+ _statusText = query('#statusText');
+
+ _isolates = new IsolateListModel();
+ _isolates.addListener(onUpdateStatus, onRequestFailed);
+ _isolates.update();
+ _updater = new Timer.repeating(_POLL_INTERVAL, (timer) => _isolates.update());
+}
+
+void onUpdateStatus(IsolateListModel model) {
+ int oldSpace = 0;
+ int newSpace = 0;
+ model.forEach((Isolate element) {
+ oldSpace += element.oldSpace.used;
+ newSpace += element.newSpace.used;
+ });
+ _graph.addSample([oldSpace, newSpace]);
+ _isolateList.updateList(model);
+ showStatus('Running ...');
+}
+
+void onRequestFailed() {
+ _updater.cancel();
+ _isolates.removeListener(onUpdateStatus);
+ showStatus('Server closed');
+}
+
+void showStatus(status) {
+ _statusText.text = status;
+}

Powered by Google App Engine
This is Rietveld 408576698