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

Side by Side Diff: runtime/observatory/tests/service/get_cpu_profile_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 // Step.
25 debugger();
26 // Allocation.
27 new Foo();
28 debugger();
29 }
30
31 var tests = [
32 hasStoppedAtBreakpoint,
turnidge 2015/07/13 23:37:48 Can you add blank lines between tests? it helps m
Cutch 2015/07/14 15:53:47 Done.
33 // Initial.
34 (Isolate isolate) async {
35 // Verify initial state of 'Foo'.
36 var fooClass = await getRootClass(isolate, 'Foo');
37 expect(fooClass, isNotNull);
38 expect(fooClass.name, equals('Foo'));
39 print(fooClass.id);
40 expect(fooClass.traceAllocations, isFalse);
41 },
42 resumeIsolate,
43 hasStoppedAtBreakpoint,
turnidge 2015/07/13 23:37:48 It looks to me like this resume/breakpoint is unne
Cutch 2015/07/14 15:53:47 There is an issue between debugger stepping and al
44 // Toggle on.
45 (Isolate isolate) async {
46 // Enable allocation tracing for 'Foo'.
47 var fooClass = await getRootClass(isolate, 'Foo');
48 await fooClass.reload();
49 expect(fooClass.traceAllocations, isFalse);
50 await fooClass.setTraceAllocations(true);
51 await fooClass.reload();
52 expect(fooClass.traceAllocations, isTrue);
53 },
54 resumeIsolate,
55 hasStoppedAtBreakpoint,
56 // Step.
turnidge 2015/07/13 23:37:48 Calling this Step is inaccurate, since we aren't s
Cutch 2015/07/14 15:53:47 Done.
57 resumeIsolate,
58 hasStoppedAtBreakpoint,
59 // Allocation profile.
60 (Isolate isolate) async {
61 var fooClass = await getRootClass(isolate, 'Foo');
62 await fooClass.reload();
63 expect(fooClass.traceAllocations, isTrue);
64 var profileResponse = await fooClass.getAllocationProfile();
65 expect(profileResponse, isNotNull);
66 expect(profileResponse['type'], equals('_CpuProfile'));
67 await fooClass.setTraceAllocations(false);
68 await fooClass.reload();
69 expect(fooClass.traceAllocations, isFalse);
70 CpuProfile cpuProfile = new CpuProfile();
turnidge 2015/07/13 23:37:48 I think we should change the name CpuProfile to so
Cutch 2015/07/14 15:53:47 I agree. The CPU profile is slowly becoming a gene
71 cpuProfile.load(isolate, profileResponse);
72 cpuProfile.buildCodeCallerAndCallees();
73 cpuProfile.buildFunctionCallerAndCallees();
74 var tree = cpuProfile.loadCodeTree('exclusive');
75 var node = tree.root;
76 var expected =
77 ['Root', 'test', 'test', '_FunctionImpl.call', 'runIsolateTests'];
78 for (var i = 0; i < expected.length; i++) {
79 expect(node.profileCode.code.name, equals(expected[i]));
80 // Depth first traversal.
81 if (node.children.length == 0) {
82 node = null;
83 } else {
84 node = node.children[0];
85 }
86 expect(node, isNotNull);
87 }
88 },
89 resumeIsolate,
90 ];
91
92 main(args) async => runIsolateTests(args, tests, testeeConcurrent:test);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698