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

Side by Side Diff: runtime/vm/object_graph_test.cc

Issue 292663012: Retaining path in Observatory. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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
« no previous file with comments | « runtime/vm/object_graph.cc ('k') | runtime/vm/service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4
5 #include "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/object_graph.h" 6 #include "vm/object_graph.h"
7 #include "vm/unit_test.h" 7 #include "vm/unit_test.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 EXPECT_EQ(a_size + b_size + c_size + d_size, 91 EXPECT_EQ(a_size + b_size + c_size + d_size,
92 graph.SizeRetainedByInstance(a)); 92 graph.SizeRetainedByInstance(a));
93 } 93 }
94 { 94 {
95 // Get hold of c again. 95 // Get hold of c again.
96 b ^= a.At(0); 96 b ^= a.At(0);
97 c ^= b.At(0); 97 c ^= b.At(0);
98 b = Array::null(); 98 b = Array::null();
99 ObjectGraph graph(isolate); 99 ObjectGraph graph(isolate);
100 // A retaining path should end like this: c <- b <- a <- ... 100 // A retaining path should end like this: c <- b <- a <- ...
101 // c itself is not included in the returned path and length.
102 { 101 {
103 HANDLESCOPE(isolate); 102 HANDLESCOPE(isolate);
104 // Test null, empty, and length 1 array. 103 // Test null, empty, and length 1 array.
105 intptr_t null_length = graph.RetainingPath(&c, Object::null_array()); 104 intptr_t null_length = graph.RetainingPath(&c, Object::null_array());
106 intptr_t empty_length = graph.RetainingPath(&c, Object::empty_array()); 105 intptr_t empty_length = graph.RetainingPath(&c, Object::empty_array());
107 Array& path = Array::Handle(Array::New(1, Heap::kNew)); 106 Array& path = Array::Handle(Array::New(1, Heap::kNew));
108 intptr_t one_length = graph.RetainingPath(&c, path); 107 intptr_t one_length = graph.RetainingPath(&c, path);
109 EXPECT_EQ(null_length, empty_length); 108 EXPECT_EQ(null_length, empty_length);
110 EXPECT_EQ(null_length, one_length); 109 EXPECT_EQ(null_length, one_length);
111 EXPECT_LE(2, null_length); 110 EXPECT_LE(3, null_length);
112 } 111 }
113 { 112 {
114 HANDLESCOPE(isolate); 113 HANDLESCOPE(isolate);
115 Array& path = Array::Handle(Array::New(2, Heap::kNew)); 114 Array& path = Array::Handle(Array::New(3, Heap::kNew));
116 intptr_t length = graph.RetainingPath(&c, path); 115 intptr_t length = graph.RetainingPath(&c, path);
117 EXPECT_LE(2, length); 116 EXPECT_LE(3, length);
117 Array& expected_c = Array::Handle();
118 expected_c ^= path.At(0);
118 Array& expected_b = Array::Handle(); 119 Array& expected_b = Array::Handle();
119 expected_b ^= path.At(0); 120 expected_b ^= path.At(1);
120 Array& expected_a = Array::Handle(); 121 Array& expected_a = Array::Handle();
121 expected_a ^= path.At(1); 122 expected_a ^= path.At(2);
123 EXPECT(expected_c.raw() == c.raw());
122 EXPECT(expected_b.raw() == a.At(0)); 124 EXPECT(expected_b.raw() == a.At(0));
123 EXPECT(expected_a.raw() == a.raw()); 125 EXPECT(expected_a.raw() == a.raw());
124 } 126 }
125 } 127 }
126 } 128 }
127 129
128 } // namespace dart 130 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object_graph.cc ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698