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

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

Issue 263803009: Retained size for instance 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/raw_object.h » ('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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // |   v 46 // |   v
47 // +-->d 47 // +-->d
48 Array& a = Array::Handle(Array::New(2, Heap::kNew)); 48 Array& a = Array::Handle(Array::New(2, Heap::kNew));
49 Array& b = Array::Handle(Array::New(2, Heap::kOld)); 49 Array& b = Array::Handle(Array::New(2, Heap::kOld));
50 Array& c = Array::Handle(Array::New(0, Heap::kOld)); 50 Array& c = Array::Handle(Array::New(0, Heap::kOld));
51 Array& d = Array::Handle(Array::New(0, Heap::kOld)); 51 Array& d = Array::Handle(Array::New(0, Heap::kOld));
52 a.SetAt(0, b); 52 a.SetAt(0, b);
53 b.SetAt(0, c); 53 b.SetAt(0, c);
54 b.SetAt(1, d); 54 b.SetAt(1, d);
55 a.SetAt(1, d); 55 a.SetAt(1, d);
56 intptr_t a_size = a.raw()->Size();
56 intptr_t b_size = b.raw()->Size(); 57 intptr_t b_size = b.raw()->Size();
57 intptr_t c_size = c.raw()->Size(); 58 intptr_t c_size = c.raw()->Size();
59 intptr_t d_size = d.raw()->Size();
58 { 60 {
59 // No more allocation; raw pointers ahead. 61 // No more allocation; raw pointers ahead.
60 NoGCScope no_gc_scope; 62 NoGCScope no_gc_scope;
61 RawObject* b_raw = b.raw(); 63 RawObject* b_raw = b.raw();
62 // Clear handles to cut unintended retained paths. 64 // Clear handles to cut unintended retained paths.
63 b = Array::null(); 65 b = Array::null();
64 c = Array::null(); 66 c = Array::null();
65 d = Array::null(); 67 d = Array::null();
66 ObjectGraph graph(isolate); 68 ObjectGraph graph(isolate);
67 { 69 {
(...skipping 11 matching lines...) Expand all
79 // Like above, but iterate over the entire isolate. The counts and sizes 81 // Like above, but iterate over the entire isolate. The counts and sizes
80 // are thus larger, but the difference should still be just 'b' and 'c'. 82 // are thus larger, but the difference should still be just 'b' and 'c'.
81 Counter with(Object::null(), Object::null()); 83 Counter with(Object::null(), Object::null());
82 graph.IterateObjects(&with); 84 graph.IterateObjects(&with);
83 Counter without(b_raw, a.raw()); 85 Counter without(b_raw, a.raw());
84 graph.IterateObjects(&without); 86 graph.IterateObjects(&without);
85 EXPECT_EQ(2, with.count() - without.count()); 87 EXPECT_EQ(2, with.count() - without.count());
86 EXPECT_EQ(b_size + c_size, 88 EXPECT_EQ(b_size + c_size,
87 with.size() - without.size()); 89 with.size() - without.size());
88 } 90 }
91 EXPECT_EQ(a_size + b_size + c_size + d_size,
92 graph.SizeRetainedByInstance(a));
89 } 93 }
90 } 94 }
91 95
92 } // namespace dart 96 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object_graph.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698