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

Side by Side Diff: runtime/observatory/tests/service/object_graph_vm_test.dart

Issue 2751423005: Run dartfmt on all files under runtime. (Closed)
Patch Set: Run dartfmt on all files under runtime. Created 3 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // VMOptions=--error_on_bad_type --error_on_bad_override 4 // VMOptions=--error_on_bad_type --error_on_bad_override
5 5
6 import 'package:observatory/heap_snapshot.dart'; 6 import 'package:observatory/heap_snapshot.dart';
7 import 'package:observatory/models.dart' as M; 7 import 'package:observatory/models.dart' as M;
8 import 'package:observatory/object_graph.dart'; 8 import 'package:observatory/object_graph.dart';
9 import 'package:observatory/service_io.dart'; 9 import 'package:observatory/service_io.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
11 import 'test_helper.dart'; 11 import 'test_helper.dart';
12 12
13 class Foo { 13 class Foo {
14 Object left; 14 Object left;
15 Object right; 15 Object right;
16 } 16 }
17
17 Foo r; 18 Foo r;
18 19
19 List lst; 20 List lst;
20 21
21 void script() { 22 void script() {
22 // Create 3 instances of Foo, with out-degrees 23 // Create 3 instances of Foo, with out-degrees
23 // 0 (for b), 1 (for a), and 2 (for staticFoo). 24 // 0 (for b), 1 (for a), and 2 (for staticFoo).
24 r = new Foo(); 25 r = new Foo();
25 var a = new Foo(); 26 var a = new Foo();
26 var b = new Foo(); 27 var b = new Foo();
27 r.left = a; 28 r.left = a;
28 r.right = b; 29 r.right = b;
29 a.left = b; 30 a.left = b;
30 31
31 lst = new List(2); 32 lst = new List(2);
32 lst[0] = lst; // Self-loop. 33 lst[0] = lst; // Self-loop.
33 // Larger than any other fixed-size list in a fresh heap. 34 // Larger than any other fixed-size list in a fresh heap.
34 lst[1] = new List(123456); 35 lst[1] = new List(123456);
35 } 36 }
36 37
37 int fooId; 38 int fooId;
38 39
39 var tests = [ 40 var tests = [
41 (Isolate isolate) async {
42 Library lib = await isolate.rootLibrary.load();
43 expect(lib.classes.length, equals(1));
44 Class fooClass = lib.classes.first;
45 fooId = fooClass.vmCid;
40 46
41 (Isolate isolate) async { 47 RawHeapSnapshot raw =
42 Library lib = await isolate.rootLibrary.load(); 48 await isolate.fetchHeapSnapshot(M.HeapSnapshotRoots.vm, false).last;
43 expect(lib.classes.length, equals(1)); 49 HeapSnapshot snapshot = new HeapSnapshot();
44 Class fooClass = lib.classes.first; 50 await snapshot.loadProgress(isolate, raw).last;
45 fooId = fooClass.vmCid; 51 ObjectGraph graph = snapshot.graph;
46 52
47 RawHeapSnapshot raw = 53 expect(fooId, isNotNull);
48 await isolate.fetchHeapSnapshot(M.HeapSnapshotRoots.vm, false).last; 54 Iterable<ObjectVertex> foos =
49 HeapSnapshot snapshot = new HeapSnapshot(); 55 graph.vertices.where((ObjectVertex obj) => obj.vmCid == fooId);
50 await snapshot.loadProgress(isolate, raw).last; 56 expect(foos.length, equals(3));
51 ObjectGraph graph = snapshot.graph; 57 expect(foos.where((obj) => obj.successors.length == 0).length, equals(1));
58 expect(foos.where((obj) => obj.successors.length == 1).length, equals(1));
59 expect(foos.where((obj) => obj.successors.length == 2).length, equals(1));
52 60
53 expect(fooId, isNotNull); 61 ObjectVertex bVertex =
54 Iterable<ObjectVertex> foos = graph.vertices.where( 62 foos.where((ObjectVertex obj) => obj.successors.length == 0).first;
55 (ObjectVertex obj) => obj.vmCid == fooId); 63 ObjectVertex aVertex =
56 expect(foos.length, equals(3)); 64 foos.where((ObjectVertex obj) => obj.successors.length == 1).first;
57 expect(foos.where((obj) => obj.successors.length == 0).length, 65 ObjectVertex rVertex =
58 equals(1)); 66 foos.where((ObjectVertex obj) => obj.successors.length == 2).first;
59 expect(foos.where((obj) => obj.successors.length == 1).length,
60 equals(1));
61 expect(foos.where((obj) => obj.successors.length == 2).length,
62 equals(1));
63 67
64 ObjectVertex bVertex = foos.where( 68 // TODO(koda): Check actual byte sizes.
65 (ObjectVertex obj) => obj.successors.length == 0).first;
66 ObjectVertex aVertex = foos.where(
67 (ObjectVertex obj) => obj.successors.length == 1).first;
68 ObjectVertex rVertex = foos.where(
69 (ObjectVertex obj) => obj.successors.length == 2).first;
70 69
71 // TODO(koda): Check actual byte sizes. 70 expect(aVertex.retainedSize, equals(aVertex.shallowSize));
71 expect(bVertex.retainedSize, equals(bVertex.shallowSize));
72 expect(
73 rVertex.retainedSize,
74 equals(
75 aVertex.shallowSize + bVertex.shallowSize + rVertex.shallowSize));
72 76
73 expect(aVertex.retainedSize, equals(aVertex.shallowSize)); 77 Library corelib =
74 expect(bVertex.retainedSize, equals(bVertex.shallowSize)); 78 isolate.libraries.singleWhere((lib) => lib.uri == 'dart:core');
75 expect(rVertex.retainedSize, equals(aVertex.shallowSize + 79 await corelib.load();
76 bVertex.shallowSize + 80 Class _List =
77 rVertex.shallowSize)); 81 corelib.classes.singleWhere((cls) => cls.vmName.startsWith('_List'));
78 82 int kArrayCid = _List.vmCid;
79 Library corelib = 83 // startsWith to ignore the private mangling
80 isolate.libraries.singleWhere((lib) => lib.uri == 'dart:core'); 84 List<ObjectVertex> lists = new List.from(
81 await corelib.load(); 85 graph.vertices.where((ObjectVertex obj) => obj.vmCid == kArrayCid));
82 Class _List = 86 expect(lists.length >= 2, isTrue);
83 corelib.classes.singleWhere((cls) => cls.vmName.startsWith('_List')); 87 // Order by decreasing retained size.
84 int kArrayCid = _List.vmCid; 88 lists.sort((u, v) => v.retainedSize - u.retainedSize);
85 // startsWith to ignore the private mangling 89 ObjectVertex first = lists[0];
86 List<ObjectVertex> lists = new List.from(graph.vertices.where( 90 ObjectVertex second = lists[1];
87 (ObjectVertex obj) => obj.vmCid == kArrayCid)); 91 // Check that the short list retains more than the long list inside.
88 expect(lists.length >= 2, isTrue); 92 expect(first.successors.length, equals(2 + second.successors.length));
89 // Order by decreasing retained size. 93 // ... and specifically, that it retains exactly itself + the long one.
90 lists.sort((u, v) => v.retainedSize - u.retainedSize); 94 expect(first.retainedSize, equals(first.shallowSize + second.shallowSize));
91 ObjectVertex first = lists[0]; 95 },
92 ObjectVertex second = lists[1];
93 // Check that the short list retains more than the long list inside.
94 expect(first.successors.length,
95 equals(2 + second.successors.length));
96 // ... and specifically, that it retains exactly itself + the long one.
97 expect(first.retainedSize,
98 equals(first.shallowSize + second.shallowSize));
99 },
100
101 ]; 96 ];
102 97
103 main(args) => runIsolateTests(args, tests, testeeBefore: script); 98 main(args) => runIsolateTests(args, tests, testeeBefore: script);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698