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

Side by Side Diff: runtime/bin/vmservice/observatory/test/gc_test.dart

Issue 460523002: Even easier observatory testing. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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) 2014, the Dart project authors. Please see the AUTHORS file 1 import 'package:observatory/service_io.dart';
2 // for details. All rights reserved. Use of this source code is governed by a 2 import 'test_helper.dart';
3 // BSD-style license that can be found in the LICENSE file.
4 3
5 library gc_test; 4 import 'dart:async';
6 5
7 import 'test_helper.dart'; 6 void script() {
8 import 'package:observatory/service_io.dart'; 7 List<int> data;
9 import 'package:unittest/unittest.dart'; 8 var grow;
10 9 grow = (int iterations, int size, Duration duration) {
11 import 'dart:io'; 10 if (iterations <= 0) {
12 11 return;
13 // Expect at least this many GC events. 12 }
14 int gcCountdown = 3; 13 data = new List<int>(size);
15 14 new Timer(duration, () => grow(iterations - 1, size, duration));
16 void onEvent(ServiceEvent event) { 15 };
17 if (event.eventType != 'GC') { 16 grow(100, 1 << 24, new Duration(seconds: 1));
18 return;
19 }
20 if (--gcCountdown == 0) {
21 exit(0);
22 }
23 } 17 }
24 18
25 main() { 19 var tests = [
26 String script = 'gc_script.dart'; 20
27 var process = new TestLauncher(script); 21 (Isolate isolate) {
28 process.launch().then((port) { 22 Completer completer = new Completer();
29 String addr = 'ws://localhost:$port/ws'; 23 // Expect at least this many GC events.
30 new WebSocketVM(new WebSocketVMTarget(addr)).get('vm') 24 int gcCountdown = 3;
31 .then((VM vm) { 25 isolate.vm.events.stream.listen((ServiceEvent event) {
32 vm.events.stream.listen(onEvent); 26 if (event.eventType == 'GC' && --gcCountdown == 0) {
33 }); 27 completer.complete();
28 }
34 }); 29 });
35 } 30 return completer.future;
31 },
32
33 ];
34
35 main(args) => runIsolateTests(args, tests, testeeConcurrent: script);
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/observatory/test/gc_script.dart ('k') | runtime/bin/vmservice/observatory/test/metrics_script.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698