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

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 debugger();
21 // Toggled on.
22 debugger();
23 debugger();
24 // Allocation.
25 new Foo();
26 debugger();
27 }
28
29 var tests = [
30 hasStoppedAtBreakpoint,
31
32 // Initial.
33 (Isolate isolate) async {
34 // Verify initial state of 'Foo'.
35 var fooClass = await getClassFromRootLib(isolate, 'Foo');
36 expect(fooClass, isNotNull);
37 expect(fooClass.name, equals('Foo'));
38 print(fooClass.id);
39 expect(fooClass.traceAllocations, isFalse);
40 await fooClass.setTraceAllocations(true);
41 await fooClass.reload();
42 expect(fooClass.traceAllocations, isTrue);
43 },
44
45 resumeIsolate,
46 hasStoppedAtBreakpoint,
47 // Extra debugger stop, continue to allow the allocation stubs to be switched
48 // over. This is a bug but low priority.
49 resumeIsolate,
50 hasStoppedAtBreakpoint,
51
52 // Allocation profile.
53 (Isolate isolate) async {
54 var fooClass = await getClassFromRootLib(isolate, 'Foo');
55 await fooClass.reload();
56 expect(fooClass.traceAllocations, isTrue);
57 var profileResponse = await fooClass.getAllocationSamples();
58 expect(profileResponse, isNotNull);
59 expect(profileResponse['type'], equals('_CpuProfile'));
60 await fooClass.setTraceAllocations(false);
61 await fooClass.reload();
62 expect(fooClass.traceAllocations, isFalse);
63 CpuProfile cpuProfile = new CpuProfile();
64 cpuProfile.load(isolate, profileResponse);
65 cpuProfile.buildCodeCallerAndCallees();
66 cpuProfile.buildFunctionCallerAndCallees();
67 var tree = cpuProfile.loadCodeTree('exclusive');
68 var node = tree.root;
69 var expected =
70 ['Root', 'test', 'test', '_FunctionImpl.call', 'runIsolateTests'];
71 for (var i = 0; i < expected.length; i++) {
72 expect(node.profileCode.code.name, equals(expected[i]));
73 // Depth first traversal.
74 if (node.children.length == 0) {
75 node = null;
76 } else {
77 node = node.children[0];
78 }
79 expect(node, isNotNull);
80 }
81 },
82 resumeIsolate,
83 ];
84
85 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