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

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

Issue 2748403002: Added page to Observatory to display native memory allocation information. (Closed)
Patch Set: Final patch. 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
« no previous file with comments | « runtime/observatory/observatory_sources.gypi ('k') | runtime/vm/malloc_hooks.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
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.
4 // VMOptions=--error_on_bad_type --error_on_bad_override
5
6 import 'dart:developer';
7 import 'package:observatory/models.dart' as M;
8 import 'package:observatory/service_io.dart';
9 import 'package:observatory/cpu_profile.dart';
10 import 'package:unittest/unittest.dart';
11 import 'service_test_common.dart';
12 import 'test_helper.dart';
13
14 void verifyHelper(var root, bool exclusive) {
15 if (root.children.length == 0) {
16 return;
17 }
18
19 /* if (!(root is FunctionCallTreeNode)) {
20 print('${root.profileCode.code.name}');
21 } else {
22 print('${root.profileFunction.function.name}');
23 }
24 */
25 int inclusiveAllocations = 0;
26 int exclusiveAllocations = 0;
27
28 for (int i = 0; i < root.children.length; i++) {
29 inclusiveAllocations += root.children[i].inclusiveNativeAllocations;
30 exclusiveAllocations += root.children[i].exclusiveNativeAllocations;
31 }
32
33 int rootMemory;
34 if (exclusive) {
35 rootMemory = root.inclusiveNativeAllocations + exclusiveAllocations;
36 } else {
37 rootMemory =
38 root.inclusiveNativeAllocations - root.exclusiveNativeAllocations;
39 }
40
41 expect(inclusiveAllocations == rootMemory, isTrue);
42 for (int i = 0; i < root.children.length; i++) {
43 verifyHelper(root.children[i], exclusive);
44 }
45 }
46
47 void verify(var tree, bool exclusive) {
48 var node = tree.root;
49 expect(node, isNotNull);
50 expect(node.children.length >= 0, isTrue);
51
52 for (int i = 0; i < node.children.length; i++) {
53 verifyHelper(node.children[i], exclusive);
54 }
55 }
56
57 var tests = [
58 // Verify inclusive tries.
59 (VM vm) async {
60 var response =
61 await vm.invokeRpc('_getNativeAllocationSamples', {'tags': 'None'});
62 CpuProfile cpuProfile = new CpuProfile();
63 await cpuProfile.load(vm, response);
64 var codeTree = cpuProfile.loadCodeTree(M.ProfileTreeDirection.inclusive);
65 var functionTree =
66 cpuProfile.loadFunctionTree(M.ProfileTreeDirection.inclusive);
67 verify(codeTree, false);
68 verify(functionTree, false);
69 },
70 // Verify exclusive tries.
71 (VM vm) async {
72 var response =
73 await vm.invokeRpc('_getNativeAllocationSamples', {'tags': 'None'});
74 CpuProfile cpuProfile = new CpuProfile();
75 await cpuProfile.load(vm, response);
76 var codeTreeExclusive =
77 cpuProfile.loadCodeTree(M.ProfileTreeDirection.exclusive);
78 var functionTreeExclusive =
79 cpuProfile.loadFunctionTree(M.ProfileTreeDirection.exclusive);
80 verify(codeTreeExclusive, true);
81 verify(functionTreeExclusive, true);
82 }
83 ];
84
85 main(args) async => runVMTests(args, tests);
OLDNEW
« no previous file with comments | « runtime/observatory/observatory_sources.gypi ('k') | runtime/vm/malloc_hooks.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698