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

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

Issue 1231603008: Expose allocation tracing over service protocol (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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
(Empty)
1 // Copyright (c) 2015, 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=--compile_all --error_on_bad_type --error_on_bad_override
5
6 import 'dart:developer';
7 import 'package:observatory/service_io.dart';
8 import 'package:observatory/cpu_profile.dart';
9 import 'package:unittest/unittest.dart';
10
11 import 'test_helper.dart';
12
13 class Foo {
14 Foo() {
15 print('new Foo');
16 }
17 }
18
19 void test() {
20 // Initial.
21 debugger();
22 // Toggle on.
23 debugger();
24 debugger();
25 // Allocation.
26 new Foo();
27 debugger();
28 }
29
30 var tests = [
31 hasStoppedAtBreakpoint,
32
33 // Initial.
34 (Isolate isolate) async {
35 // Verify initial state of 'Foo'.
36 var fooClass = await getClassFromRootLib(isolate, 'Foo');
37 expect(fooClass, isNotNull);
38 expect(fooClass.name, equals('Foo'));
39 print(fooClass.id);
40 expect(fooClass.traceAllocations, isFalse);
41 },
42
43 resumeIsolate,
44 hasStoppedAtBreakpoint,
turnidge 2015/07/14 18:34:20 Delete this?
45
46 // Toggle on.
47 (Isolate isolate) async {
48 // Enable allocation tracing for 'Foo'.
49 var fooClass = await getClassFromRootLib(isolate, 'Foo');
50 await fooClass.reload();
51 expect(fooClass.traceAllocations, isFalse);
52 await fooClass.setTraceAllocations(true);
53 await fooClass.reload();
54 expect(fooClass.traceAllocations, isTrue);
55 },
56
57 resumeIsolate,
58 hasStoppedAtBreakpoint,
59 // Extra debugger stop, continue to allow the allocation stubs to be switched
60 // over.
turnidge 2015/07/14 18:34:20 Say that this is a bug, but low priority...
61 resumeIsolate,
62 hasStoppedAtBreakpoint,
63
64 // Allocation profile.
65 (Isolate isolate) async {
66 var fooClass = await getClassFromRootLib(isolate, 'Foo');
67 await fooClass.reload();
68 expect(fooClass.traceAllocations, isTrue);
69 var profileResponse = await fooClass.getAllocationSamples();
70 expect(profileResponse, isNotNull);
71 expect(profileResponse['type'], equals('_CpuProfile'));
72 await fooClass.setTraceAllocations(false);
73 await fooClass.reload();
74 expect(fooClass.traceAllocations, isFalse);
75 CpuProfile cpuProfile = new CpuProfile();
76 cpuProfile.load(isolate, profileResponse);
77 cpuProfile.buildCodeCallerAndCallees();
78 cpuProfile.buildFunctionCallerAndCallees();
79 var tree = cpuProfile.loadCodeTree('exclusive');
80 var node = tree.root;
81 var expected =
82 ['Root', 'test', 'test', '_FunctionImpl.call', 'runIsolateTests'];
83 for (var i = 0; i < expected.length; i++) {
84 expect(node.profileCode.code.name, equals(expected[i]));
85 // Depth first traversal.
86 if (node.children.length == 0) {
87 node = null;
88 } else {
89 node = node.children[0];
90 }
91 expect(node, isNotNull);
92 }
93 },
94 resumeIsolate,
95 ];
96
97 main(args) async => runIsolateTests(args, tests, testeeConcurrent:test);
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/service/object.dart ('k') | runtime/observatory/tests/service/test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698