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

Side by Side Diff: runtime/bin/vmstats/vmstats.dart

Issue 12793003: Rename Timer.repeating to Timer.periodic. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart.vmstats; 5 library dart.vmstats;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:json' as JSON; 9 import 'dart:json' as JSON;
10 10
11 part 'bargraph.dart'; 11 part 'bargraph.dart';
12 part 'isolate_list.dart'; 12 part 'isolate_list.dart';
13 part 'models.dart'; 13 part 'models.dart';
14 14
15 BarGraph _graph; 15 BarGraph _graph;
16 IsolateList _isolateList; 16 IsolateList _isolateList;
17 DivElement _statusText; 17 DivElement _statusText;
18 IsolateListModel _isolates; 18 IsolateListModel _isolates;
19 Timer _updater; 19 Timer _updater;
20 20
21 final int _POLL_INTERVAL_IN_MS = 1000; 21 final int _POLL_INTERVAL = const Duration(seconds: 1);
22 22
23 void main() { 23 void main() {
24 DivElement dashBoard = query('#dashboard'); 24 DivElement dashBoard = query('#dashboard');
25 CanvasElement canvas = query('#graph'); 25 CanvasElement canvas = query('#graph');
26 var elements = [ new Element("Old Space", "#97FFFF"), 26 var elements = [ new Element("Old Space", "#97FFFF"),
27 new Element("New Space", "#00EE76")]; 27 new Element("New Space", "#00EE76")];
28 _graph = new BarGraph(canvas, elements); 28 _graph = new BarGraph(canvas, elements);
29 UListElement isolateListElement = query('#isolateList'); 29 UListElement isolateListElement = query('#isolateList');
30 _isolateList = new IsolateList(isolateListElement); 30 _isolateList = new IsolateList(isolateListElement);
31 _statusText = query('#statusText'); 31 _statusText = query('#statusText');
32 32
33 _isolates = new IsolateListModel(); 33 _isolates = new IsolateListModel();
34 _isolates.addListener(onUpdateStatus, onRequestFailed); 34 _isolates.addListener(onUpdateStatus, onRequestFailed);
35 _isolates.update(); 35 _isolates.update();
36 _updater = 36 _updater = new Timer.periodic(_POLL_INTERVAL, (timer) => _isolates.update());
37 new Timer.repeating(_POLL_INTERVAL_IN_MS, (timer) => _isolates.update());
38 } 37 }
39 38
40 void onUpdateStatus(IsolateListModel model) { 39 void onUpdateStatus(IsolateListModel model) {
41 int oldSpace = 0; 40 int oldSpace = 0;
42 int newSpace = 0; 41 int newSpace = 0;
43 model.forEach((Isolate element) { 42 model.forEach((Isolate element) {
44 oldSpace += element.oldSpace.used; 43 oldSpace += element.oldSpace.used;
45 newSpace += element.newSpace.used; 44 newSpace += element.newSpace.used;
46 }); 45 });
47 _graph.addSample([oldSpace, newSpace]); 46 _graph.addSample([oldSpace, newSpace]);
48 _isolateList.updateList(model); 47 _isolateList.updateList(model);
49 showStatus('Running ...'); 48 showStatus('Running ...');
50 } 49 }
51 50
52 void onRequestFailed() { 51 void onRequestFailed() {
53 _updater.cancel(); 52 _updater.cancel();
54 _isolates.removeListener(onUpdateStatus); 53 _isolates.removeListener(onUpdateStatus);
55 showStatus('Server closed'); 54 showStatus('Server closed');
56 } 55 }
57 56
58 void showStatus(status) { 57 void showStatus(status) {
59 _statusText.text = status; 58 _statusText.text = status;
60 } 59 }
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/timer_patch.dart » ('j') | tests/isolate/timer_not_available_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698